new Crypto() → {object}
AeroGear.Crypto is used to provide various crypto methods
- Source:
Returns:
agCrypto - The created Crypto Object
- Type
- object
Example
// Create a AeroGear.Crypto Object
var agCrypto = AeroGear.Crypto();
Classes
Methods
-
decrypt(options) → {bitArray}
-
Decrypts in GCM mode
Parameters:
Name Type Description options
Object includes IV (Initialization Vector), AAD (Additional Authenticated Data), key (private key for encryption), ciphertext (data to be decrypted) - Source:
Returns:
- The decrypted data- Type
- bitArray
Example
//Data decryption: var options = { IV: myIV, AAD: myAAD, key: mySecretKey, data: ciphertext }; AeroGear.Crypto().decrypt( options );
-
deriveKey(password, providedSalt) → {bitArray}
-
Returns the value of the key
Parameters:
Name Type Description password
String master password providedSalt
Number salt provided to recreate the key - Source:
Returns:
- the derived key- Type
- bitArray
Example
//Password encryption: AeroGear.Crypto().deriveKey( 'mypassword', 42 );
-
encrypt(options) → {bitArray}
-
Encrypts in GCM mode
Parameters:
Name Type Description options
Object includes IV (Initialization Vector), AAD (Additional Authenticated Data), key (private key for encryption), plainText (data to be encrypted) - Source:
Returns:
- The encrypted data represented by an array of bytes- Type
- bitArray
Example
//Data encryption: var options = { IV: myIV, AAD: myAAD, key: mySecretKey, data: message }; AeroGear.Crypto().encrypt( options );
-
getRandomValue() → {Number}
-
Returns the random value
- Source:
Returns:
- the random value- Type
- Number
Example
//Random number generator: AeroGear.Crypto().getRandomValue();