Node-uuid can quickly generate UUID that complies with RFC4122 Specification version 1 or version 4. The js-base64 can realize Base64 encoding and decoding, and supports UTF-8 encoding. Crypto-js can be very convenient in JavaScript MD5, SHA1, SHA2, SHA3, RIPEMD-160 hash, AES, DES, Rabbit, RC4, Triple DES encryption and decryption. SJCL is a project created by the computer security lab of Stanford University. it aims to create a secure, fast, short, easy-to-use, cross-browser JavaScript encryption library.
Node-uuidNode-uuid can quickly generate UUID (Universally Unique IDentifier) that complies with RFC4122 Specification version 1 or version 4 ). The emergence of UUID is to uniquely identify each information entity in a complex system without a centralized id management. That is to say, a rule is used to assign a unique id to an information entity, and an id manager is not required to ensure the uniqueness of this id. UUID is a 128-bit globally unique identifier, usually represented by a 32-byte string. It ensures the uniqueness of the generated ID through MAC address, timestamp, namespace, random number, and pseudo-random number. Version 1 is time-based, and version 1 is random ( Version1:
[AppleScript] Var uuidv1 = require ('../lib/uuid/we-uuidv1'); console. log (uuidv1 (); // output: 70d47fd0-d250-11e6-9816-45a4888ae4f
Version4: [AppleScript] Var uuidv4 = require ('../lib/uuid/we-uuidv4'); console. log (uuidv4 (); // output: d839476c-ce27-4d24-a431-e96123c1916b Generate parameters can be set [AppleScript] Var v1 = uuidv1 ({node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab], clockseq: 0x1234, msecs: new Date (). getTime (), nsecs: 5678}); console. log (v1); // output: 908e3a9e-d250-11e6-9234-0123456789ab
The js-base64 can realize Base64 encoding and decoding, and supports UTF-8 encoding. Base64 is a representation of binary data based on 64 printable characters. Because the power of 6 in 2 is equal to 64, every 6 bits are a unit and correspond to a printable character. The three bytes have 24 bits, which correspond to four Base64 units. that is, the three bytes are represented by four printable characters. It can be used as the transmission code of the email. The printable characters in Base64 include letters A-Z, a-z, and numbers 0-9, which have A total of 62 characters. the Two printable characters are different in different systems. Base64 is actually a simple replacement encryption method, but BASE64 is often not used to prevent information leakage, and to facilitate transmission, after BASE64 encoding, the information will be longer than the original information, about 4/3 times. Encoding: Console. log (Base64.encode ('WeChat '));// Output: v2vjaf0Console. log (Base64.encode (''));// Output: 5b6u5L + hDecoding: Console. log (Base64.decode ('v2vjarf0 '));// Output: WechatConsole. log (Base64.decode ('5b6u5l + h '));// Output:Crypto-jsCrypto-js can be very convenient in JavaScript MD5, SHA1, SHA2, SHA3, RIPEMD-160 hash, AES, DES, Rabbit, RC4, Triple DES encryption and decryption. CryptoJS (crypto. js) provides various encryption algorithms for JavaScript. Currently, the supported algorithms include:
MD5
SHA-1
SHA-256
AES
Rabbit
MARC4
HMAC
HMAC-MD5
HMAC-SHA1
HMAC-SHA256
PBKDF2
MD5: Console. log (CryptoJS. MD5 ('WeChat'). toString ());// Output: 98ffdc1f1a326c9f73bbe0b78e1d180eSHA1: Console. log (CryptoJS. SHA1 ('WeChat'). toString ());// Output: 42989457d716a8b89f99c687a10979d4242b5491SHA256: Console. log (CryptoJS. SHA256 ('WeChat'). toString ());// Output: SuccessSJCLSJCL is a project created by the computer security laboratory of Stanford University, it is designed to create a secure, fast, short, easy-to-use, cross-browser JavaScript encryption library. SJCL uses the industry standard AES 128,192,256-bit encryption; SHA256 hash function; HMAC verification code; PBKDF2 cryptographic enhancement; CCM and OCB authentication encryption mode. Encryption: VarEnStr = sjcl. encrypt ("password", "Wechat"); console. log (enStr );Decryption: VarDeStr = sjcl. decrypt ("password", enStr); console. log (deStr );References
Others
|