mirror of
https://github.com/cupcakearmy/occulto.git
synced 2026-04-02 20:15:29 +00:00
2.0.0 (#3)
* rewrite * testing worklflow * sprcify version * config stuff * add hash as buffer * delete docs * use typedarray everywhere and docs * readme * aes * cleanup * rsa * testing with playwright * fix playwright * readme * docs * update deps * use headless * add prepublish * build pipeline * move types up * move types up * add types legacy * packaging * versions bump * cleanup * maybe this time * drop support for commonjs * version bump * cleanup
This commit is contained in:
28
test/aes.spec.js
Normal file
28
test/aes.spec.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { AES, Bytes, Hashes, Hex } from '../dist/index.js'
|
||||
import { Precomputed } from './values.js'
|
||||
|
||||
describe('AES', () => {
|
||||
it('Basic API', async () => {
|
||||
const message = Precomputed.Crypto.Messages.nietzscheIpsum
|
||||
const data = Bytes.encode(message)
|
||||
const [key] = await AES.derive('foo', {
|
||||
name: 'PBKDF2',
|
||||
hash: Hashes.SHA_512,
|
||||
iterations: 1000,
|
||||
length: 256,
|
||||
salt: Hex.decode(Precomputed.Crypto.Bytes[16]),
|
||||
})
|
||||
const ciphertext = await AES.encrypt(data, key, AES.Modes.GCM)
|
||||
const plaintext = await AES.decrypt(ciphertext, key)
|
||||
chai.expect(data).to.be.deep.equal(plaintext)
|
||||
chai.expect(message).to.be.equal(Bytes.decode(plaintext))
|
||||
})
|
||||
|
||||
it('Easy API', async () => {
|
||||
const message = Precomputed.Crypto.Messages.nietzscheIpsum
|
||||
const password = 'foobar'
|
||||
const encrypted = await AES.encryptEasy(message, password)
|
||||
const decrypted = await AES.decryptEasy(encrypted, password)
|
||||
chai.expect(message).to.be.equal(decrypted)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user