Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from "@angular/core";
- import { LanguageModel } from './languageModel';
- import { LocationModel } from './locationModel';
- import { JobModel } from './jobModel';
- @Injectable()
- export class PersonModel {
- public id: number = null;
- public joiningDate: number = null;
- public lastAccessDate: number = null;
- public userName: string = null;
- public password: string = null;
- public firstName: string = null;
- public lastName: string = null;
- public emailAddress: string = null;
- public locations: LocationModel[] = [];
- public languages: LanguageModel[] = [];
- public time: string = null;
- public avatar: string = null;
- public avatar64: string = null;
- private CryptoJS: any = null;
- private SECERET_KEY: string = 'secret key 123';
- require.config({
- packages: [
- {
- name: 'crypto-js',
- location: 'path-to/bower_components/crypto-js',
- main: 'index'
- }
- ]
- });
- require(["crypto-js/aes", "crypto-js/sha256"], function (AES, SHA256) {
- console.log(SHA256("Message"));
- });
- constructor() {
- this.CryptoJS = require("crypto-js");
- }
- public getPasswordEcrypted(): string {
- // Decrypt
- var bytes = this.CryptoJS.AES.decrypt(this.password.toString(), this.SECERET_KEY);
- var plaintext = bytes.toString(this.CryptoJS.enc.Utf8);
- return plaintext;
- }
- public setPasswordEncrypted(password: string): void {
- // Encrypt
- var ciphertext = this.CryptoJS.AES.encrypt(password, this.SECERET_KEY);
- this.password = ciphertext;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement