ismx-nexo-node-app 0.4.181 → 0.4.182
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { KeyLike, RsaPrivateKey } from "crypto";
|
|
1
2
|
export default abstract class CryptoUtils {
|
|
2
3
|
private static crypto;
|
|
3
4
|
private static zeroPad;
|
|
4
5
|
static symEncrypt(key: string, message: string): Promise<Buffer>;
|
|
5
6
|
static symDecrypt(key: string, encrypted: Buffer): Promise<string>;
|
|
6
7
|
/** Asymmetric encryption (RSA) */
|
|
7
|
-
static asymEncrypt(value: string, publicKey:
|
|
8
|
+
static asymEncrypt(value: string, publicKey: RsaPrivateKey | KeyLike): Promise<string>;
|
|
8
9
|
/** Asymmetric decryption (RSA) */
|
|
9
|
-
static asymDecrypt(hash: string, privateKey:
|
|
10
|
+
static asymDecrypt(hash: string, privateKey: RsaPrivateKey | KeyLike): Promise<string>;
|
|
10
11
|
private static sha256Sign;
|
|
11
12
|
}
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {privateDecrypt, publicEncrypt} from "node:crypto";
|
|
2
|
+
import {KeyLike, RsaPrivateKey} from "crypto";
|
|
2
3
|
|
|
3
4
|
export default abstract class CryptoUtils {
|
|
4
5
|
|
|
@@ -48,14 +49,14 @@ export default abstract class CryptoUtils {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
/** Asymmetric encryption (RSA) */
|
|
51
|
-
static async asymEncrypt(value: string, publicKey:
|
|
52
|
+
static async asymEncrypt(value: string, publicKey: RsaPrivateKey | KeyLike): Promise<string> {
|
|
52
53
|
const buffer = Buffer.from(value, 'utf8');
|
|
53
54
|
const encrypted = publicEncrypt(publicKey, buffer);
|
|
54
55
|
return encrypted.toString('base64');
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/** Asymmetric decryption (RSA) */
|
|
58
|
-
static async asymDecrypt(hash: string, privateKey:
|
|
59
|
+
static async asymDecrypt(hash: string, privateKey: RsaPrivateKey | KeyLike): Promise<string> {
|
|
59
60
|
const buffer = Buffer.from(hash, 'base64');
|
|
60
61
|
const decrypted = privateDecrypt(privateKey, buffer);
|
|
61
62
|
return decrypted.toString('utf8');
|