edo999
edo999
Explore posts from servers
DDeno
Created by edo999 on 7/4/2024 in #help
How to use crypto generateKeyPairSync?
I'm trying to make generateKeyPairSync work, but it fails. The sample code at the bottom of https://docs.deno.com/api/node/crypto/~/generateKeyPairSync does not work on deno 1.44.4 (MacOS Sonoma 14.5 M2 chip). I get:
error: Uncaught (in promise) Error: Not implemented: crypto.PrivateKeyObject.prototype.export
const { publicKey, privateKey } = generateKeyPairSync("rsa", {
^
at notImplemented (ext:deno_node/_utils.ts:9:9)
at PrivateKeyObject.export (ext:deno_node/internal/crypto/keys.ts:206:5)
at generateKeyPairSync (ext:deno_node/internal/crypto/keygen.ts:77:37)
at file:///deno/test.ts:3:35
error: Uncaught (in promise) Error: Not implemented: crypto.PrivateKeyObject.prototype.export
const { publicKey, privateKey } = generateKeyPairSync("rsa", {
^
at notImplemented (ext:deno_node/_utils.ts:9:9)
at PrivateKeyObject.export (ext:deno_node/internal/crypto/keys.ts:206:5)
at generateKeyPairSync (ext:deno_node/internal/crypto/keygen.ts:77:37)
at file:///deno/test.ts:3:35
I get the same thing with generateKeyPair. The only way it works, is if I remove the both key encodings from the options:
const { generateKeyPairSync } = await import("node:crypto");

const { publicKey, privateKey } = generateKeyPairSync("rsa", {
modulusLength: 4096,
});
const { generateKeyPairSync } = await import("node:crypto");

const { publicKey, privateKey } = generateKeyPairSync("rsa", {
modulusLength: 4096,
});
What am I doing wrong?
2 replies
HHono
Created by edo999 on 7/3/2024 in #help
Get the user IP address
Is there no better way to get the user IP address than doing this 👇🏽? https://github.com/EdamAme-x/deno-deploy-hono-ip/blob/main/entry.ts It works, but it's a bit convoluted. FYI, I use the IP address to implement a rate limiter.
3 replies