Ad

Using Node's crypto module.

Code
Diff
  • const crypto = require('crypto');
    
    let databaseUser = { 
        email : "tvorchesky@mail.com", 
        password : "6827ef24aa9c59195dc19cbc2b597f6d" /* password nya adalah Taralolet123, udah di enkripsi pakai MD5 */
      };
    
    function login(email, password) {
      let passHash = crypto.createHash('md5').update(password).digest("hex");
      return email === databaseUser.email && passHash === databaseUser.password ? true : false;
    };
    • var databaseUser = [
    • {
    • const crypto = require('crypto');
    • let databaseUser = {
    • email : "tvorchesky@mail.com",
    • password : "6827ef24aa9c59195dc19cbc2b597f6d" /* password nya adalah Taralolet123, udah di enkripsi pakai MD5 */
    • }
    • ];
    • };
    • function login(email, password){
    • // TODO : implementasikan code berdasar test case dibawah
    • }
    • function login(email, password) {
    • let passHash = crypto.createHash('md5').update(password).digest("hex");
    • return email === databaseUser.email && passHash === databaseUser.password ? true : false;
    • };