我的密码在角度应用中如何安全?

时间:2018-06-29 14:41:11

标签: angular5 cryptojs

我需要发送一些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?
  }

}

Live Demo

0 个答案:

没有答案