File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change 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" ) ;
You can’t perform that action at this time.
0 commit comments