Simple Javascript cryptography library that wraps incompatible WebCrypto implementations, utilizes encryption algorithms that all WebCrypto enabled browsers support and provides a much simpler interface.
var data = new Uint8Array([5,4,3,2,1]);
var logError = function() {
console.log(arguments);
}
var aesKey = new Uint8Array([1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6]);
var hmacKey = new Uint8Array([1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6]);
simpleCrypto.sym.encrypt(keys, data, logError, function(encrypted) {
simpleCrypto.sym.decrypt(keys, encrypted, logError.bind(null, done), function(decrypted) {});
});
simpleCrypto.asym.generateEncryptKey(logError, function(keys){
simpleCrypto.asym.encrypt(key.publicKey, data, logError, function(encrypted) {
simpleCrypto.asym.decrypt(key.privateKey, encrypted, logError.bind(null, done), function(decrypted){});
});
});
Please see Unit Tests for more examples
Q: Why another Javascript Crypto library?
A: Simplecrypto is built on top of WebCrypto and IndexedDB. Performance advantage over other libraries is
significant.
IndexedDB provides for safer storage of Javascript keys.
Q: Why AES-CBC-HMAC instead of AES-GCM?
A: WebKit does not support AES-GCM.
Q: PBKDF2?
A: Safari, IE and Chrome on Linux do not support PBKDF2, but support HMAC-SHA1.
Small shim is used to implement PBKDF2 in thise cases. Elsewhere, native PBKDF2 support is used.
Apache 2.0