denoland / std

The Deno Standard Library
https://jsr.io/@std
MIT License
3.01k stars 603 forks source link

Bug in module hash/mod #3677

Closed JoanaBLate closed 11 months ago

JoanaBLate commented 12 months ago

After some time producing hashes, Deno crashes.

PROGRAM

"use strict"

import { createHash } from "https://deno.land/std@0.91.0/hash/mod.ts"

function showHashes(secretKey) {    

    let n = -1

    while (true) {

        n += 1

        const hash = createHash("md5")

        hash.update(secretKey + n)

        const hashed = hash.toString()

        if (hashed.startsWith("00000")) { console.log(secretKey + n, hashed) }
    }
}

showHashes("wtnhxymk")

OUTPUT

wtnhxymk2231254 0000027b9705c7e6fa3d4816c490bbfd wtnhxymk2440385 00000468c8625d85571d250737c47b5a wtnhxymk2640705 0000013e3293b49e4c78a5b43b21023b wtnhxymk3115031 0000040bbe4509b48041007dec6123bd wtnhxymk5045682 00000b11810477f9e49840991fb2151e wtnhxymk8562236 00000cc461c8945671046cf632be4473 wtnhxymk9103137 000007c1da6865df78b2c0addf28913d wtnhxymk9433034 00000700ce8beb0a8ffc83fa9986d577 wtnhxymk9669127 00000d76f344ea0a8643bb2bcf0323c4 wtnhxymk13753308 0000050301b17d598b52e2a343b80c95 wtnhxymk13976178 000006fe7545b487de2d003f3d4e1114 wtnhxymk15855849 000002d5272322770ff5e60b01455753 wtnhxymk16774052 000004f449e36332d8693c3a84f8bf70 wtnhxymk16837862 000002f6b67f02f6c7565a041503ea65 error: Uncaught RangeError: offset is out of bounds getUint8Memory0().set(arg, ptr / 1); ^ at Uint8Array.set () at passArray8ToWasm0 (https://deno.land/std@0.91.0/hash/_wasm/wasm.js:141:21) at update_hash (https://deno.land/std@0.91.0/hash/_wasm/wasm.js:151:14) at Hash.update (https://deno.land/std@0.91.0/hash/_wasm/hash.ts:47:5) at showHashes (file:///home/fclm/advent-of-code/2016/day05/crap.js:15:14) at file:///home/fclm/advent-of-code/2016/day05/crap.js:23:1

lino-levan commented 12 months ago

std/hash has been deprecated for almost a year now. Your code is using version 0.91.0 while the latest release is 0.203.0. If you update your code to use the built-in crypto API, it should work fine.

JoanaBLate commented 11 months ago

Thanks!

lucacasonato commented 11 months ago

Closing because std/hash is deprecated.