Files
xahau.js/packages/isomorphic/test/sha256.test.ts
Nicholas Dudfield 217b111ef2 feat: use @noble and @scure libraries for cryptography (#2273)
Switch to using `@noble/hashes`, `@noble/curves`, `@scure/base`,
`@scure/bip32`, and `@scure/bip39`. This replaces `crypto` polyfills
(such as `crypto-browserify`), `create-hash`, `elliptic`, `hash.js`,
`bn.js` (both versions), and their many dependencies.  This also means
there are 33 less dependencies downloaded when running a fresh
`npm install` and will make the project much easier to maintain.

This reduces the bundle size by 44% (82kb minified and gzipped) over
the current 3.0 branch as well as reducing the amount of configuration
required to bundle.

Closes #1814, #1817, #2272, and #2306

Co-authored-by: Caleb Kniffen <ckniffen@ripple.com>
2024-02-01 13:50:19 -06:00

18 lines
499 B
TypeScript

import { sha256 } from '@xrplf/isomorphic/sha256'
import { bytesToHex } from '@xrplf/isomorphic/utils'
describe('sha256', () => {
it('hashes', () => {
const hashA = sha256('abc')
const hashB = sha256
.create()
.update(Uint8Array.from([97, 98, 99]))
.digest()
const expectedHash =
'BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD'
expect(bytesToHex(hashA)).toEqual(expectedHash)
expect(bytesToHex(hashB)).toEqual(expectedHash)
})
})