<commit_before>var ACH = require('../lib/ach');
var should = require('chai').should();

describe('ACH (ACHCBCHMAC)', function() {
  
  describe('@encrypt', function() {
    
    it('should encrypt data', function() {
      var data = new Buffer([0]);
      var cipherkey = new Buffer(256 / 8);
      cipherkey.fill(0x12);
      var encbuf = ACH.encrypt(data, cipherkey);
      encbuf.length.should.equal(256 / 8 + 256 / 8);
    });

  });

  describe('@decrypt', function() {
    
    it('should decrypt data', function() {
      var encbuf = new Buffer('7519aff134f4fd273b41e50e6b9fac4d39b42afe6c2335551a4c06c4bdf9198d667b0dd26e935fdd5454e99ab27d8c17404199c79cb0c9d3884d2bd5bbd2b619', 'hex');
      var cipherkey = new Buffer(256 / 8);
      cipherkey.fill(0x12);
      var data = ACH.decrypt(encbuf, cipherkey);
      data.toString('hex').should.equal('00');
    });

  });

});<commit_msg>add some test vectors generated with sjcl<commit_after>var ACH = require('../lib/ach');
var should = require('chai').should();

describe('ACH (AES+CBC+HMAC)', function() {
  
  describe('@encrypt', function() {
    
    it('should encrypt data', function() {
      var data = new Buffer([0]);
      var cipherkey = new Buffer(256 / 8);
      cipherkey.fill(0x12);
      var encbuf = ACH.encrypt(data, cipherkey);
      encbuf.length.should.equal(256 / 8 + 256 / 8);
    });

    it('should encrypt this data and get a known value generated with sjcl', function() {
      var data = new Buffer('this is my test data');
      var cipherkey = new Buffer(256 / 8);
      cipherkey.fill(0x70);
      var ivbuf = new Buffer(128 / 8);
      ivbuf.fill(0x07);
      var encbuf = ACH.encrypt(data, cipherkey, ivbuf);
      var enchex = '<KEY>';
      encbuf.toString('hex').should.equal(enchex);
    });

  });

  describe('@decrypt', function() {
    
    it('should decrypt data', function() {
      var encbuf = new Buffer('<KEY>', 'hex');
      var cipherkey = new Buffer(256 / 8);
      cipherkey.fill(0x12);
      var data = ACH.decrypt(encbuf, cipherkey);
      data.toString('hex').should.equal('00');
    });

    it('should decrypt this encrypted data generated by sjcl', function() {
      var ptbuf = new Buffer('this is my test data');
      var pthex = ptbuf.toString('hex');
      var encbuf = new Buffer('5ca7fb171ef5001fdc26aca9ca806279200a8dd9bc3580b95d80335ed358627e07070707070707070707070707070707a1e5dd6b76089f0c055d718c9f597d22d727422cb1a28dd1a30aacb0cb008c1d', 'hex');
      var cipherkey = new Buffer(256 / 8);
      cipherkey.fill(0x70);
      var data = ACH.decrypt(encbuf, cipherkey);
      data.toString('hex').should.equal(pthex);
    });

  });

});
{'fraction_non_alphanumeric': 0.15101427498121714, 'fraction_numerical': 0.09729526671675431, 'mean_word_length': 3.288244766505636, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1814863', 'n_tokens_mistral': 1097, 'n_tokens_neox': 931, 'n_words': 194}