add encryption

This commit is contained in:
2020-03-04 14:51:22 +01:00
parent 6649dd23fd
commit 850515cc42
3 changed files with 100 additions and 1 deletions

21
test/encryption.js Normal file
View File

@ -0,0 +1,21 @@
'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);
});