mirror of
https://github.com/cupcakearmy/occulto.git
synced 2026-04-02 20:25: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:
23
test/hash.spec.js
Normal file
23
test/hash.spec.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Bytes, Hash, Hashes, Hex } from '../dist/index.js'
|
||||
import { Precomputed } from './values.js'
|
||||
|
||||
describe('Hash', () => {
|
||||
for (const type of Object.keys(Hashes)) {
|
||||
describe(type, () => {
|
||||
const values = Precomputed.Hash[type]
|
||||
for (const [input, output] of Object.entries(values)) {
|
||||
it(`Should hash "${input}" to "${output.slice(0, 8)}..."`, async () => {
|
||||
const hashed = await Hash.hash(input, Hashes[type])
|
||||
chai.expect(hashed).to.equal(output)
|
||||
})
|
||||
|
||||
it(`Should hash "${input}" to "${output.slice(0, 8)}..." as buffer`, async () => {
|
||||
const outputBuffer = Hex.decode(output)
|
||||
const inputBuffer = Bytes.encode(input)
|
||||
const hashed = await Hash.hash(inputBuffer, Hashes[type])
|
||||
chai.expect(hashed).to.deep.equal(outputBuffer)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user