Hi All,
How do you import the Crypto-js
?
I try the the following:
import { CryptoJS } from '../../../node_modules/crypto-js';
@Injectable()
export class PersonModel {
public password: string = null;
private CryptoJS: any = null;
private SECERET_KEY: string = 'secret key 123';
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;
}
}
But get the following compile error:
[ts] Module '"e:/Development/IDE/ionic-apps/theWhoZoo/node_modules/crypto-js/index"' has no exported member 'CryptoJS'. import CryptoJS
Please see:
http://stackoverflow.com/questions/40467395/javascript-library-of-crypto-standards-implementation