new Crypto() → {object}
Status: Experimental
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();
Extends
- AeroGear.Core
Methods
-
decrypt(options) → {bitArray}
-
Status: Experimental
Decrypts in GCM modeParameters:
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}
-
Status: Experimental
Returns the value of the keyParameters:
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}
-
Status: Experimental
Encrypts in GCM modeParameters:
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}
-
Status: Experimental
Returns the random value- Source:
Returns:
- the random value- Type
- Number
Example
// Random number generator: AeroGear.Crypto().getRandomValue();
-
hash(data) → {bitArray}
-
Status: Experimental
Generates a hash output based on SHA-256Parameters:
Name Type Description data
bitArray | String to hash. - Source:
Returns:
- Hash value- Type
- bitArray
Example
// Data hashing: AeroGear.Crypto().hash( options );
-
KeyPair(prKey, pubKey) → {Object}
-
Status: Experimental
Initialize the key pair with the keys providedParameters:
Name Type Description prKey
Object private key pubKey
Object public key - Source:
Returns:
the object containing the key pair- Type
- Object
Example
AeroGear.Crypto().KeyPair();
-
sign(options) → {bitArray}
-
Status: Experimental
Sign messages with ECDSAParameters:
Name Type Description options
Object includes keys (provided keys to sign the message), message (message to be signed) - Source:
Returns:
- Digital signature- Type
- bitArray
Example
// Message sign: var options = { keys: providedKey, message: PLAIN_TEXT }; AeroGear.Crypto().sign( options );
-
verify(options) → {bitArray}
-
Status: Experimental
Verify signed messages with ECDSAParameters:
Name Type Description options
Object includes keys (provided keys to sign the message), message (message to be verified), signature (Digital signature) - Source:
Returns:
- Signature- Type
- bitArray
Example
// Message validation var options = { keys: sjcl.ecc.ecdsa.generateKeys(192), signature: signatureToBeVerified }; AeroGear.Crypto().verify( options );