2021-03-14 02:42:46 -05:00
|
|
|
import { aesDecrypt, aesEncrypt } from '../../../../src/lib/crypto-utils';
|
|
|
|
import { convertPayloadToBase64 } from '../../../../src/lib/utils';
|
2019-09-07 17:46:50 -05:00
|
|
|
|
|
|
|
describe('test crypto utils', () => {
|
2021-03-14 02:42:46 -05:00
|
|
|
describe('default encryption', () => {
|
|
|
|
test('decrypt payload flow', () => {
|
|
|
|
const payload = 'juan';
|
|
|
|
const token = aesEncrypt(Buffer.from(payload), '12345').toString('base64');
|
2019-09-07 17:46:50 -05:00
|
|
|
|
2021-03-14 02:42:46 -05:00
|
|
|
const data = aesDecrypt(convertPayloadToBase64(token), '12345').toString('utf8');
|
2019-09-07 17:46:50 -05:00
|
|
|
|
2021-03-14 02:42:46 -05:00
|
|
|
expect(payload).toEqual(data);
|
|
|
|
});
|
|
|
|
});
|
2019-09-07 17:46:50 -05:00
|
|
|
});
|