Javascript AES Encryption Library. Encrypt and Decrypt messages using an Encryption Key. Based on the implementation of the AES block cipher @: http://point-at-infinity.org/jsaes/
The cription object provides access to the methods.
##Cription.encrypt(...) Encrypts a secret with a key.
var cription = new Cription();
var options = {
secret : "mySecret",
key : "myEncryptionKey1",
store : false
};
var encrypted_secret = cription.encrypt(options);
###Parameters
- secret: The string that is encrypted.
- key: (Optional) The key that encrypts the secret.
- store: (Optional) The option to save key
myKey
to localStorage('key').Default == false
###Description
If a key is not provided/valid an automatically generated key will be used.
Keys must be [16,24,32] chars in length and hexadecimal
If options.store == true
then localStorage.key == options.key
.
##Cription.decrypt(...) Decrypts an encrypted secret with a key.
var options = {
secret : encrypted_secret,
key : "myEncryptionKey1",
};
var decrypted_secret = cription.decrypt(options);
###Parameters
- secret: The encrypted secret.
- key: (Optional) The key that decrypts the secret.
###Description If a key is not provided/valid then the key saved in localStorage will be used.
##Cription.generateKey(...) Creates a random, valid key.
var myKey = myCription.generateKey(n);
###Parameters
- n: number of characters. n=[16,24,32];
###Description Use this if a random, non-customized password is required. If n is not one of 16, 24 or 32 an error is thrown.
var myCription = new Cription();
var encrypted_secret = myCription.encrypt({secret:"mySecret", store:true});
//Generates a random key and stores it to "localStorage.key".
//Auto-generated keys will print to console.log on encryption.
var decrypted_secret = myCription.decrypt({secret:encrypted_secret});
//decrypts the encrypted secret with key stored in "localStorage.key"
console.log(decrypted_secret);//"mySecret"
Example: http://cs1.ucc.ie/~jdp2/cription/