crypto-helper/test/encryption.js
2020-03-04 15:01:39 +01:00

22 lines
502 B
JavaScript

'use strict';
const test = require ('ava');
const crypto = require ('../index');
test ('encryption', (t) => {
const enc = crypto.encrypt_aes ('foo', 'bar');
t.is (typeof enc, 'string');
});
test ('decryption', (t) => {
const enc = crypto.encrypt_aes ('foo', 'bar');
const dec = crypto.decrypt_aes (enc, 'bar');
t.is (dec, 'foo');
});
test ('fail decryption', (t) => {
const enc = crypto.encrypt_aes ('foo', 'bar');
const dec = crypto.decrypt_aes (enc, 'baz');
t.is (dec, null);
});