Error: Digest method not supported

I want use node:crypto module So i followed this doc https://developers.cloudflare.com/workers/runtime-apis/nodejs/#:~:text=Log%20in%20to%20the%20Cloudflare%20dashboard%20and%20select,compatibility%20flag%20to%20your%20Preview%20and%20Production%20deployments. I added compatibility_flags = ['nodejs_compat'] in wrangler.toml and code: import crypto from 'node:crypto' hash = crypto.createHash(method) hash.update(date); hash.update(email) const hdateemail = hash.digest(encoding) console.log(hdateemail) It works perfectly when use 'npm run dev' but when use 'npx wrangler dev', it not works Error: Digest method not supported ps. I also added flags on cli like 'npx wrangler dev --compatibility_flags nodejs_compat' and not works at all..
Node.js compatibility · Cloudflare Workers docs
Implemented Node.js runtime APIs and enablement instructions for your Worker project.
No description
11 Replies
kian
kian5mo ago
What is npm run dev doing?
sv._.342
sv._.3425mo ago
vite dev
kian
kian5mo ago
You should use wrangler dev for testing Workers. In this case, you're probably using an unsupported encoding.
sv._.342
sv._.3425mo ago
Oh okay.. i'll try change encoding
kian
kian5mo ago
It's probably an issue with crypto.createHash(method) more than hash.digest(encoding)
sv._.342
sv._.3425mo ago
but.. Cloudflare doc redirects to Nodejs doc and Nodejs doc can support hex... anyway i'll try different encoding
No description
sv._.342
sv._.3425mo ago
i changed encoding to 'base64' but not works. same error
kian
kian5mo ago
Like I said, more likely to be an issue with createHash(method)
sv._.342
sv._.3425mo ago
ahhh misunderstand sorry.. bad eng
kian
kian5mo ago
Cloudflare uses BoringSSL which means shake128 and shake256 aren't supported iirc
sv._.342
sv._.3425mo ago
oh thanks! it works