0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-20 22:52:46 -05:00
verdaccio/packages/auth/test/crypto-utils.spec.ts
Juan Picado fbd761c8ee refactor: auth-utils (#1951)
* chore: refactor auth utils

* chore: relocate crypto utils
2021-04-09 17:54:21 +02:00

15 lines
499 B
TypeScript

import { convertPayloadToBase64 } from '@verdaccio/utils';
import { aesDecrypt, aesEncrypt } from '../src/crypto-utils';
describe('test crypto utils', () => {
describe('default encryption', () => {
test('decrypt payload flow', () => {
const payload = 'juan';
const token = aesEncrypt(Buffer.from(payload), '12345').toString('base64');
const data = aesDecrypt(convertPayloadToBase64(token), '12345').toString('utf8');
expect(payload).toEqual(data);
});
});
});