2020-08-13 23:27:00 +02:00
|
|
|
import { aesDecrypt, aesEncrypt, convertPayloadToBase64 } from '../src';
|
2020-03-03 23:59:19 +01:00
|
|
|
|
|
|
|
describe('test crypto utils', () => {
|
2020-08-13 23:27:00 +02:00
|
|
|
describe('default encryption', () => {
|
|
|
|
test('decrypt payload flow', () => {
|
|
|
|
const payload = 'juan';
|
|
|
|
const token = aesEncrypt(Buffer.from(payload), '12345').toString('base64');
|
2020-03-03 23:59:19 +01:00
|
|
|
|
2020-08-13 23:27:00 +02:00
|
|
|
const data = aesDecrypt(convertPayloadToBase64(token), '12345').toString('utf8');
|
2020-03-03 23:59:19 +01:00
|
|
|
|
2020-08-13 23:27:00 +02:00
|
|
|
expect(payload).toEqual(data);
|
|
|
|
});
|
|
|
|
});
|
2020-03-03 23:59:19 +01:00
|
|
|
});
|