blob: 4bf5b8a45cf9d1624de866e6af40a5dcaac864a9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
import { decrypt, encrypt } from '@peertube/peertube-server/server/helpers/peertube-crypto.js'
describe('Encrypt/Descrypt', function () {
it('Should encrypt and decrypt the string', async function () {
const secret = 'my_secret'
const str = 'my super string'
const encrypted = await encrypt(str, secret)
const decrypted = await decrypt(encrypted, secret)
expect(str).to.equal(decrypted)
})
it('Should not decrypt without the same secret', async function () {
const str = 'my super string'
const encrypted = await encrypt(str, 'my_secret')
let error = false
try {
await decrypt(encrypted, 'my_sicret')
} catch (err) {
error = true
}
expect(error).to.be.true
})
})
|