Hemmelig.app/tests/server/helpers/crypto.test.js

19 lines
521 B
JavaScript
Raw Normal View History

import assert from 'assert';
2021-06-14 18:40:32 +02:00
import { decrypt, encrypt, generateKey } from '../../../shared/helpers/crypto.js';
2021-06-14 18:40:32 +02:00
const SECRET = 'MASTER_KEY=1337-super-secret';
const RANDOM_KEY = generateKey();
2021-06-24 08:47:21 +02:00
2021-06-14 18:40:32 +02:00
describe('Crypto', () => {
describe('#encrypt(string)', () => {
it('should encrypt, and decrypt a secret', async () => {
const encrypted = encrypt(SECRET, RANDOM_KEY);
const decrypted = decrypt(encrypted, RANDOM_KEY);
2021-06-14 18:40:32 +02:00
assert.equal(decrypted, SECRET);
});
});
});