<commit_before><commit_msg>import and typings for aes-js, plus a unit test for simple encrypt/decrypt<commit_after>/// <reference path='../../../third_party/typings/jasmine/jasmine.d.ts' />
/// <reference path='../../../third_party/aes-js/aes-js.d.ts' />

import aesjs = require('aes-js');
import arraybuffers = require('../arraybuffers/arraybuffers');

describe('aes', function() {
  it('simple encrypt/decrypt', () => {
    // aesjs.util.convertStringToBytes works too
    var key = new Uint8Array(arraybuffers.stringToArrayBuffer('Example128BitKey'));
    var iv = new Uint8Array(arraybuffers.stringToArrayBuffer('IVMustBe16Bytes.'));

    var text = 'TextMustBe16Byte';
    var textBytes = new Uint8Array(arraybuffers.stringToArrayBuffer(text));

    var cbc1 = new aesjs.ModeOfOperation.cbc(key, iv);
    var encryptedBytes = cbc1.encrypt(textBytes);

    var cbc2 = new aesjs.ModeOfOperation.cbc(key, iv);
    var decryptedBytes = cbc2.decrypt(encryptedBytes);
    // NOTE: Cannot use arraybuffers.arrayBufferToString due to lack of buffer
    //       field in the returned instance.
    var decryptedText = aesjs.util.convertBytesToString(decryptedBytes);

    expect(decryptedText).toEqual(text);
  });
});
{'fraction_non_alphanumeric': 0.14238683127572016, 'fraction_numerical': 0.011522633744855968, 'mean_word_length': 4.1308016877637135, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4288584', 'n_tokens_mistral': 405, 'n_tokens_neox': 386, 'n_words': 79}