#forge.js availability
11 messages · Page 1 of 1 (latest)
Unsure, what are you trying to do?
i wast trying to implement api in cloudflare worker to generate deviceId but my function uses crypto library and i don't find the same function in cloudflare crypto:
using nodejs crypto lib.
function getDeviceI() {
let id = crypto.randomBytes(20).toString("binary");
let hmac = crypto.createHmac(
"sha1",
Buffer.from(
"E7309ECC0953C6FA60005B2765F99DBBC965C8E9",
"hex"
)
);
hmac.update(Buffer.from(Buffer.from("19", "hex") + id, "binary"));
return "19" + Buffer.from(id, "binary").toString("hex") + hmac.digest("hex");
}
correct deviceId:19CEB4EB9340402020E054720BEBAF280A8CEA373CC6E00629C9CEB1B3CB14FD5ABC0D4F5896DBAD4E
Hey, very shortly, if not already, you should be able to access the node:crypto and node:buffer modules in your worker, you just need to add a compatibility flag of nodejs_compat to your wrangler.toml
u mean the node js crypto? or the crypto that already have in cloudflare worker?
name = "cloudflare-workers"
main = "src/index.js"
compatibility_date = "2023-07-31"
compatibility_flags = [ "nodejs_compat" ]
i didn't found node:crypto
I mean node's crypto, it should be here soon
so it's not in worker currently right?
If you've tried it, and it;s not working, then it will soon
ok