Advertisement
Guest User

Untitled

a guest
Nov 7th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. import { Injectable } from "@angular/core";
  2. import { LanguageModel } from './languageModel';
  3. import { LocationModel } from './locationModel';
  4. import { JobModel } from './jobModel';
  5.  
  6. @Injectable()
  7. export class PersonModel {
  8.  
  9. public id: number = null;
  10. public joiningDate: number = null;
  11. public lastAccessDate: number = null;
  12. public userName: string = null;
  13. public password: string = null;
  14. public firstName: string = null;
  15. public lastName: string = null;
  16. public emailAddress: string = null;
  17. public locations: LocationModel[] = [];
  18. public languages: LanguageModel[] = [];
  19. public time: string = null;
  20. public avatar: string = null;
  21. public avatar64: string = null;
  22.  
  23. private CryptoJS: any = null;
  24. private SECERET_KEY: string = 'secret key 123';
  25.  
  26. require.config({
  27. packages: [
  28. {
  29. name: 'crypto-js',
  30. location: 'path-to/bower_components/crypto-js',
  31. main: 'index'
  32. }
  33. ]
  34. });
  35.  
  36. require(["crypto-js/aes", "crypto-js/sha256"], function (AES, SHA256) {
  37. console.log(SHA256("Message"));
  38. });
  39.  
  40. constructor() {
  41. this.CryptoJS = require("crypto-js");
  42.  
  43. }
  44.  
  45. public getPasswordEcrypted(): string {
  46. // Decrypt
  47. var bytes = this.CryptoJS.AES.decrypt(this.password.toString(), this.SECERET_KEY);
  48. var plaintext = bytes.toString(this.CryptoJS.enc.Utf8);
  49. return plaintext;
  50. }
  51.  
  52. public setPasswordEncrypted(password: string): void {
  53. // Encrypt
  54. var ciphertext = this.CryptoJS.AES.encrypt(password, this.SECERET_KEY);
  55. this.password = ciphertext;
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement