Skip to content

Commit 31b42f9

Browse files
committed
Update version to 1.3.1 and refactor decryption to use RSA with private key
1 parent 289a54c commit 31b42f9

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hecate-keystone",
3-
"version": "1.2.0",
3+
"version": "1.3.1",
44
"type": "module",
55
"description": "A secrets manager for my JavaScript projects.",
66
"main": "src/index.js",

src/crypto.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import CryptoJS from 'crypto-js';
1+
import { privateDecrypt } from 'crypto';
22

33
/**
4-
* Decrypts a message using AES decryption with the provided key
5-
* @param {string} encryptedMessage - The encrypted message
6-
* @param {string} encryptionKey - The decryption key (same as encryption key)
7-
* @returns {string} Decrypted message as a string
4+
* Decrypts a message using RSA decryption with the provided private key
5+
* @param encryptedMessage - The encrypted message as a base64 string
6+
* @param privateKey - The RSA private key in PEM format
7+
* @returns Decrypted message as a string
88
*/
9-
export function decrypt(encryptedMessage, encryptionKey) {
9+
export function decrypt(encryptedMessage, privateKey) {
1010
try {
11-
const decrypted = CryptoJS.AES.decrypt(encryptedMessage, encryptionKey);
12-
return decrypted.toString(CryptoJS.enc.Utf8);
11+
const buffer = Buffer.from(encryptedMessage, 'base64');
12+
const decrypted = privateDecrypt(privateKey, buffer);
13+
return decrypted.toString('utf8');
1314
} catch (error) {
1415
console.error("Decryption error:", error);
1516
throw new Error("Failed to decrypt message");

0 commit comments

Comments
 (0)