How to use the aes function from node-forge

Find comprehensive JavaScript node-forge.aes code examples handpicked from public code repositorys.

229
230
231
232
233
234
235
236
237
238
var key = keyczar_util.decodeBase64Url(data.key);

var derivedKey = _deriveKey(password, salt, data.iterationCount);

// decrypt the key with the derived key
var cipher = forge.aes.startDecrypting(derivedKey, iv, null);
cipher.update(new forge.util.ByteBuffer(key));
var success = cipher.finish();
if (!success) {
    throw new Error(PBE_DECRYPT_FAILED_MESSAGE);
fork icon17
star icon38
watch icon9

+ 3 other calls in file

257
258
259
260
261
262
263
264
265
266
var iterationCount = _DEFAULT_ITERATIONS;
var salt = forge.random.getBytes(_SALT_BYTES);
var derivedKey = _deriveKey(password, salt, iterationCount);

var iv = forge.random.getBytes(_PBE_AES_KEY_BYTES);
var cipher = forge.aes.startEncrypting(derivedKey, iv, null);
cipher.update(new forge.util.ByteBuffer(keyString));
var success = cipher.finish();
if (!success) {
    throw new Error('AES encryption failed');
fork icon0
star icon0
watch icon0

379
380
381
382
383
384
385
386
387
388
389
390


    return keyczar_util._aesFromBytes(keyBytes, hmacBytes);
};


keyczar_util._aesFromBytes = function(keyBytes, hmacBytes) {
    var aesObject = forge.aes.createEncryptionCipher(keyBytes);
    var mdObject = forge.md.sha1.create();
    var hmacObject = forge.hmac.create();
    hmacObject.start(mdObject, hmacBytes);

fork icon0
star icon0
watch icon0

+ 5 other calls in file