Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
How to convert Node crypto.generateKeyPairSync to Deno?

I want to convert the following code from a Node (v18.1) program to Deno (v1.22), where a key pair is generated during SSH key exchange:

// generate.mjs
import { generateKeyPairSync } from "crypto";

const keys = generateKeyPairSync("x25519");

The code above is part of a larger SSH client, which mostly works in Deno when run in Node compatibility mode (--compat). However, generateKeyPairSync is not yet implemented, so I want to change it to a Deno equivalent:

deno run --compat --unstable --allow-env ./generate.mjs

error: Uncaught Error: Not implemented: crypto.generateKeyPairSync
  throw new Error(message);
        ^
    at notImplemented (https://deno.land/std@0.142.0/node/_utils.ts:22:9)
    at generateKeyPairSync (https://deno.land/std@0.142.0/node/internal/crypto/keygen.ts:662:3)
    at file:///C:/Users/gjzwiers/repos/nodeno_ssh/generate.mjs:3:14

I have looked at generateKey in the WebCrypto API, but it seems that it does not support x25519? Is there an alternative for x25519 in the WebCrypto API , or is there another way to get this working in Deno?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I ended up using an external module as suggested in the comments. I used node-forge to generate a keypair, which works nicely when run in Node compatibility mode for Deno:

// run with: deno run --compat --unstable --allow-env --allow-read generate.mjs
import forge from 'node-forge';

const ed25519 = forge.pki.ed25519;

const keypair = ed25519.generateKeyPair();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!