convert PKCS#1 keys to PKCS#8 at load time

This commit is contained in:
2026-02-25 21:55:09 -06:00
parent 3d7db8b132
commit 29b5c986cd
3 changed files with 30 additions and 26 deletions
@@ -6,12 +6,8 @@ export const generateSecureValue = (content: string) => {
// Generate a hash of the content
const hash = Password.hash(content);
// Parse the PKCS#1 PEM key into a proper KeyObject
const publicKey = crypto.createPublicKey({
key: secureValuesPublicKey,
format: "pem",
type: "pkcs1",
});
// Parse the PEM key into a proper KeyObject
const publicKey = crypto.createPublicKey(secureValuesPublicKey);
// Encrypt the content using the .secureValues.pub public key
const encrypted = crypto.publicEncrypt(
+1 -5
View File
@@ -3,11 +3,7 @@ import crypto from "crypto";
import { secureValuesPrivateKey } from "../../constants";
import GenericError from "../../Errors/GenericError";
const privateKey = crypto.createPrivateKey({
key: secureValuesPrivateKey,
format: "pem",
type: "pkcs1",
});
const privateKey = crypto.createPrivateKey(secureValuesPrivateKey);
export const readSecureValue = (
encryptedContent: string,