1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { expect } from 'chai'
4 import { decrypt, encrypt } from '@server/helpers/peertube-crypto'
6 describe('Encrypt/Descrypt', function () {
8 it('Should encrypt and decrypt the string', async function () {
9 const secret = 'my_secret'
10 const str = 'my super string'
12 const encrypted = await encrypt(str, secret)
13 const decrypted = await decrypt(encrypted, secret)
15 expect(str).to.equal(decrypted)
18 it('Should not decrypt without the same secret', async function () {
19 const str = 'my super string'
21 const encrypted = await encrypt(str, 'my_secret')
26 await decrypt(encrypted, 'my_sicret')
31 expect(error).to.be.true