22 lines
502 B
JavaScript
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);
|
||
|
});
|