我需要发送一些secret
值给后备。为此,我使用了Crypto-js
。工作正常。
我的问题是secretCode
的申请安全性如何?如果有人从源中获取了secretCode
代码。.是否有可能encode
的值?
这是我的代码:如果有正确的加密方法,请告诉我。
import { Component, OnInit } from '@angular/core';
import * as CryptoJS from 'crypto-js';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
message = "SuperSecret!!";
secretCode = "madukkarai"; //from view source this is available..!
encrypted:any;
decrypted:any;
constructor(){}
ngOnInit(){
this.encrypted = CryptoJS.AES.encrypt(this.message, this.secretCode);
console.log('encrypted', this.encrypted.toString() );
this.decript();
}
decript(){
var decrypted = CryptoJS.AES.decrypt(this.encrypted, this.secretCode);
this.decrypted = decrypted.toString(CryptoJS.enc.Utf8);
console.log('decripted'); //any one can do this?
}
}