/* * * * * * * hmac-sha1encryption * * * * * * * *
var? Content? =? Password'; //Encrypt plaintext;
var? Token 1=' Mi Yue'; //encryption key;
var? buf? =? crypto . random bytes( 16);
token 1? =? buf . tostring(' hex '); //Key encryption;
Console.log ("Generated token (key used for encryption):"+token1);
var? secret key = token 1; //key;
var? Signature? =? crypto.createHmac('sha 1 ',? secret key); //Define the encryption method
Signture.update (content);
var? miwen = Signture.digest()。 toString(' base64 '); //The generated ciphertext will be used as plaintext again, and then iteratively encrypted by pbkdf2 algorithm;
Console.log ("encrypted result f:"+miwen);
/* * * * * * * * * (the generated result is different every time) * * * * * * * * * * * * * * *, the corresponding result.
Generated token (key used for encryption): de7c3dafede518a1ad9c2096ee9b4feff.
The result of encryption f: pux7fnomlqvj+bs9o6rnngxfy =
Generated token (key used for encryption): 93fee046ebf47412c2d54c1e808218d2.
The result of encryption f:/erkukwxzgXnm7wczu8rax5o =