我是Angular 2的新手。我正在尝试实现一个登录表单,在某些加密步骤之后将emailid和密码发送到服务器。
我已经通过使用AES-CTR实现了AES-ECB,
https://github.com/diafygi/webcrypto-examples
导入密钥
'和'
加密
"方法如下:,
public deriveAKey(input, encryptKey, cryptoIV) {
var ref: TopDivComponent = this;
console.log('Testing before importKey...');
window.crypto.subtle.importKey(
"raw",
ref.stringToArrayBuffer(encryptKey),
{
name: "AES-CTR",
},
true,
["encrypt"]
).then(function (key) {
console.log('Inside then...');
var newvar = ref.stringToArrayBuffer(cryptoIV);
var encrypt = window.crypto.subtle.encrypt(
{
name: "AES-CTR",
counter: newvar,
length: 128,
},
key,
ref.stringToArrayBuffer(input)
).then(function (encrypted) {
var temp = ref.arrayBufferToString(encrypted);
console.log('Encrypted First: ' + encrypted);
console.log('Temp: ' + temp);
console.log('Key: ' + key);
let fin_encrypted = btoa(temp);
// console.log('Encrypted Snc/d: ' + fin_encrypted);
ref.response(fin_encrypted);
// console.log('From deriveKey: ' + fin_encrypted);
});
});
}
NotSupportedError:只允许安全来源
.
当我使用
铬金丝雀