JavaScript加密庫 jsCrypto
jsCrypto 是一個實現了一些常用加密方法的 JavaScript 庫,支持的算法包括:
- Symmetric encryption: AES, DES, 3DES,
- Encryption mode: ECB, CBC, CTR,
- Digest algorithm: SHA-1, SHA256,
- Message Authentication Code (MAC): HMAC, CBCMAC, CMAC
- Random number generator (RNG): FIPS186, X9.17,
- Public key cryptography: RSA, DSA, ECC, CPK, IBE
功能特性:
- Performance heavily enhanced.
- Object oriented architecture, with a single namespace, and you can extend the framework with your own algorithms.
- Support Init, Upate, Final pattern for bulk data processing for most algorithms.
- Parllellized computing, even long term operation will not block the browser.
- Support a key storage interface, with multiple implementations.
- Support local file system access, users can upload a local file into the browser DOM tree and then processed with jscrypto algorithms.
這個庫也可以在 ActionScript 下使用。
示例代碼:
var cipher = jscrypto.aes; var key = 'password'; var iv = 'initialvector'; var encryptor = new jscrypto.cbcmode.encryptor(cipher, key, iv); var ctext = new Array(); ctext.concat(encryptor.update('hello')); ctext.concat(encryptor.update('world')); ctext.concat(encryptor.final()); document.write(ctext);
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!