WebCrypto
- 部分浏览器要求 HTTPS
- 参考
- Web Crypto API
- sha256
- https://lapo.it/asn1js/
- travist/jsencrypt
- 非常古早的加密库
- OpenSSL RSA Encryption, Decryption, Key Generation
- https://travistidwell.com/jsencrypt/demo/
- PKCS#5 #35
- brix/crypto-js
- 不再维护
- safebash/opencrypto
- 支持的算法
- ⚠️ 不支持 RSASSA-PKCS1-v1_5
- format
- raw
- pkcs8 - PKCS #8
- PKCS#1 是旧的格式
- spki - SubjectPublicKeyInfo
- jwk
- PKCS5
# pkcs1 -> pkcs8
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in pkcs1.key -out pkcs8.key
Member RsaHashedImportParams.hash is required and must be an instance of (object or DOMString)
await crypto.subtle.importKey('raw', PEM.decode(key).block.bytes, 'RSA-OAEP', false, ['decrypt']);
await crypto.subtle.importKey(
'raw',
PEM.decode(key).block.bytes,
{
name: 'RSA-OAEP',
hash: 'SHA-265',
},
false,
['decrypt'],
);