Advertisement
Guest User

Untitled

a guest
Aug 30th, 2017
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. login(username, password) {
  2.  
  3. let crypted = crypto.AES.encrypt(password, "secret");
  4.  
  5. let data_base64 = crypted.ciphertext.toString(crypto.enc.Base64);
  6. let iv_base64 = crypted.iv.toString(crypto.enc.Base64);
  7. let key_base64 = crypted.key.toString(crypto.enc.Base64);
  8.  
  9. this.http.get('apiurl/login/user=' + username + ',pass=' + base_64 + ',iv=' + iv_base64 + ',key=' + key_base64)
  10. .map(res => res.json())
  11. .subscribe(
  12. data => console.log(data), //localStorage.setItem('id_token', data.jwt)
  13. error => console.log(error)
  14. );
  15. }
  16.  
  17. $encrypted = base64_decode($pass["data_base64"]);
  18. $iv = base64_decode($pass["iv_base64"]);
  19. $key = base64_decode($pass["key_base64"]);
  20.  
  21. $plaintext = mcrypt_decrypt( MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv );
  22.  
  23. // remove padding added by crypt algorithms
  24. $plaintext = rtrim($plaintext, "t "); // remove tab-, zero- and space-padding
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement