回答

3

是的,你可以用AES或其他算法加密/解密你的数据。也许你可以尝试实施https://github.com/digitalbazaar/forge#md5

// generate a random key and IV 
 
// Note: a key size of 16 bytes will use AES-128, 24 => AES-192, 32 => AES-256 
 
var key = forge.random.getBytesSync(16); 
 
var iv = forge.random.getBytesSync(16); 
 

 
/* alternatively, generate a password-based 16-byte key 
 
var salt = forge.random.getBytesSync(128); 
 
var key = forge.pkcs5.pbkdf2('password', salt, numIterations, 16); 
 
*/ 
 

 
// encrypt some bytes using CBC mode 
 
// (other modes include: CFB, OFB, CTR, and GCM) 
 
var cipher = forge.cipher.createCipher('AES-CBC', key); 
 
cipher.start({iv: iv}); 
 
cipher.update(forge.util.createBuffer(someBytes)); 
 
cipher.finish(); 
 
var encrypted = cipher.output; 
 
// outputs encrypted hex 
 
console.log(encrypted.toHex()); 
 

 
// decrypt some bytes using CBC mode 
 
// (other modes include: CFB, OFB, CTR, and GCM) 
 
var decipher = forge.cipher.createDecipher('AES-CBC', key); 
 
decipher.start({iv: iv}); 
 
decipher.update(encrypted); 
 
decipher.finish(); 
 
// outputs decrypted hex 
 
console.log(decipher.output.toHex());

+1

我有伪造的教程和加密为好。 https://blog.nraboy.com/2014/10/implement-aes-strength-encryption-javascript/ –

+0

@Nic Raboy-我们需要存储密钥,有些是我们用于加密的。如果有人获得移动应用程序的密钥和代码,那么它将很容易解密数据,因为我们在我们的移动应用程序中有加密和解密代码。对? –

+0

正确,这就是为什么你每次想要使用应用程序时都必须让用户输入密钥。只有密钥正确才能解密? –

相关问题