Skip to content

Commit

Permalink
hash224
Browse files Browse the repository at this point in the history
  • Loading branch information
imaman committed Nov 13, 2024
1 parent fb814a0 commit c5ef05e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/septima-lang/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class Runtime {
})

const parse = Value.foreign(o => JSON.parse(o.toString()))
const hash = Value.foreign(o => crypto.createHash('sha224').update(JSON.stringify(o.unwrap())).digest('hex'))
const hash224 = Value.foreign(o => crypto.createHash('sha224').update(JSON.stringify(o.unwrap())).digest('hex'))

let lib = new SymbolFrame('Object', { destination: Value.obj({ keys, entries, fromEntries }) }, empty, 'INTERNAL')
lib = new SymbolFrame('String', { destination: Value.foreign(o => Value.str(o.toString())) }, lib, 'INTERNAL')
Expand All @@ -108,7 +108,7 @@ export class Runtime {
lib = new SymbolFrame('Array', { destination: Value.obj({ isArray }) }, lib, 'INTERNAL')
lib = new SymbolFrame('console', { destination: Value.obj({ log }) }, lib, 'INTERNAL')
lib = new SymbolFrame('JSON', { destination: Value.obj({ parse }) }, lib, 'INTERNAL')
lib = new SymbolFrame('crypto', { destination: Value.obj({ hash }) }, lib, 'INTERNAL')
lib = new SymbolFrame('crypto', { destination: Value.obj({ hash224 }) }, lib, 'INTERNAL')

if (generateTheArgsObject) {
lib = new SymbolFrame('args', { destination: Value.from(this.args) }, lib, 'INTERNAL')
Expand Down
2 changes: 1 addition & 1 deletion modules/septima-lang/tests/septima.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ describe('septima', () => {
describe('hash', () => {
test('foo', () => {
const hashOf = (u: unknown) => crypto.createHash('sha224').update(JSON.stringify(u)).digest('hex')
expect(run(`crypto.hash('A')`)).toEqual(hashOf('A'))
expect(run(`crypto.hash224('A')`)).toEqual(hashOf('A'))
})
})
test.todo('sort') // expect(run(`[4, 10, 9, 256, 5, 300, 2, 70].sort()`)).toEqual('--')
Expand Down

0 comments on commit c5ef05e

Please sign in to comment.