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:
I get the same thing with generateKeyPair
.
The only way it works, is if I remove the both key encodings from the options:
What am I doing wrong?1 Reply
I apologize for the inconvenience, but I wasn't able to find the answer to your question in the official Deno documentation. However, based on the error message you've provided, it seems that the
crypto.PrivateKeyObject.prototype.export
method is not implemented in your current version of Deno.
The error message indicates that the export
method on PrivateKeyObject
is not available, which suggests that the issue might be related to the specific encoding options you are using for the keys. Since you mentioned that removing the key encodings from the options makes it work, it seems that the problem is indeed related to the key encoding.
Here's the part of your code that seems to be causing the issue:
Since I cannot provide a solution based on the Deno documentation, I recommend double-checking the compatibility of the key encoding options you are using with the version of Deno you have installed. It's possible that the version of Deno you are using does not support certain encoding options for key generation.
Please note that this advice is not based on the Deno documentation, and I advise you to double-check the accuracy of the advice given. If you continue to experience issues, you may want to consider reaching out to the Deno community or checking the GitHub issues for Deno to see if others have encountered and resolved similar problems.