Skip to content

Crypto

Generate random values and keys.

import { std } from "vyft";
export const token = std.crypto.randomBytes("token", {
length: 32,
encoding: "hex",
});
FieldTypeDescription
lengthnumberrequired — Number of bytes
encoding"hex" | "base64"Output encoding
export const password = std.crypto.randomString("password", {
length: 24,
alphabet: "abcdefghijklmnopqrstuvwxyz0123456789",
});
FieldTypeDescription
lengthnumberrequired — String length
alphabetstringCharacter set to use
export const pin = std.crypto.randomInteger("pin", {
min: 100000,
max: 999999,
});
FieldTypeDescription
minnumberrequired — Minimum value
maxnumberrequired — Maximum value
export const id = std.crypto.randomUuid("id");

No arguments needed.

export const key = std.crypto.sshKeyPair("key", {
type: "ed25519",
});
FieldTypeDescription
type"ed25519" | "rsa"required — Key type
rsaBitsnumberRSA key size (default 4096)

Output: privateKeyPem, publicKeyPem, fingerprint