Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda