加密/解密庫libsodium的一個JavaScript實現:libsodium.js
libsodium.js是C++加密/解密庫libsodium的一個純JavaScript實現。 它提供了一些易于在Web應用程序中使用的接口。整個庫只有133 KB(縮小的,gzip壓縮),并能在Web瀏覽器,以及服務器端運行。
<script>
window.sodium = { onload: function(sodium) {
alert(sodium.to_hex(sodium.crypto_generichash(64, 'test')));
}};
</script>
...
<script src="sodium.js" async defer></script>已實現的算法和功能列表:
- crypto_aead (ChaCha20-Poly1305)
- crypto_auth (SHA256, SHA512, and the default crypto_auth with SHA512/256)
- crypto_box
- crypto_generichash (Blake2b)
- crypto_hash (SHA512/256)
- crypto_pwhash (scrypt)
- crypto_scalarmult (Curve25519)
- crypto_secretbox
- crypto_shorthash (SipHash)
- crypto_sign (Ed25519)
- Ed25519->Curve25519 conversion
- randombytes </ul>
- from_base64(),to_base64()
- from_hex(),to_hex()
- memcmp()(constant-time comparison, returnstrueorfalse)
- memzero()(applies toUint8Arrayobjects) </ul>
額外的幫助類
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!