Open this example in the interactive library
Source code
import {
createHash,
createHmac,
randomUUID,
randomBytes,
timingSafeEqual,
generateKeyPairSync,
sign,
verify,
createSecretKey,
} from "node:crypto";
console.log(
(() => {
const { privateKey, publicKey } = generateKeyPairSync("ed25519");
const data = Buffer.from("demo");
return verify(null, data, publicKey, sign(null, data, privateKey));
})(),
);
Sample output
true
