encrypt-rsa 3.2.0 → 4.0.0

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.
Files changed (39) hide show
  1. package/README.md +217 -154
  2. package/build/node/node/convertKetToBase64.d.ts +6 -0
  3. package/build/{functions → node/node}/convertKetToBase64.js +5 -1
  4. package/build/node/node/crypto.d.ts +6 -0
  5. package/build/node/node/crypto.js +98 -0
  6. package/build/node/node/index.d.ts +17 -0
  7. package/build/{index.js → node/node/index.js} +17 -18
  8. package/build/node/shared/helpers.d.ts +32 -0
  9. package/build/node/shared/helpers.js +101 -0
  10. package/build/node/shared/types.d.ts +68 -0
  11. package/build/web/shared/helpers.d.ts +32 -0
  12. package/build/web/shared/helpers.js +101 -0
  13. package/build/web/shared/types.d.ts +68 -0
  14. package/build/web/shared/types.js +2 -0
  15. package/build/web/web/convertKetToBase64.d.ts +6 -0
  16. package/build/web/web/convertKetToBase64.js +13 -0
  17. package/build/web/web/crypto.d.ts +6 -0
  18. package/build/web/web/crypto.js +165 -0
  19. package/build/web/web/index.d.ts +17 -0
  20. package/build/web/web/index.js +77 -0
  21. package/package.json +24 -7
  22. package/build/functions/convertKetToBase64.d.ts +0 -2
  23. package/build/functions/createPrivateAndPublicKeys.d.ts +0 -3
  24. package/build/functions/createPrivateAndPublicKeys.js +0 -47
  25. package/build/functions/decrypt.d.ts +0 -3
  26. package/build/functions/decrypt.js +0 -37
  27. package/build/functions/decryptStringWithRsaPrivateKey.d.ts +0 -3
  28. package/build/functions/decryptStringWithRsaPrivateKey.js +0 -37
  29. package/build/functions/encrypt.d.ts +0 -3
  30. package/build/functions/encrypt.js +0 -37
  31. package/build/functions/encryptStringWithRsaPublicKey.d.ts +0 -3
  32. package/build/functions/encryptStringWithRsaPublicKey.js +0 -37
  33. package/build/functions/index.d.ts +0 -5
  34. package/build/functions/index.js +0 -21
  35. package/build/index.d.ts +0 -17
  36. package/build/utils/helpers.d.ts +0 -2
  37. package/build/utils/helpers.js +0 -21
  38. package/build/utils/types.d.ts +0 -20
  39. /package/build/{utils → node/shared}/types.js +0 -0
@@ -0,0 +1,17 @@
1
+ import type { parametersOfDecrypt, parametersOfDecryptPublic, parametersOfEncrypt, parametersOfEncryptPrivate, returnCreateKeys, INodeRSA } from '../shared/types';
2
+ export type { returnCreateKeys, parametersOfEncrypt, parametersOfDecrypt, parametersOfEncryptPrivate, parametersOfDecryptPublic, INodeRSA, } from '../shared/types';
3
+ declare class NodeRSA implements INodeRSA {
4
+ private publicKey;
5
+ private privateKey;
6
+ private modulusLength;
7
+ private keyBase64;
8
+ constructor(publicKey?: string, privateKey?: string, modulusLength?: number);
9
+ encryptStringWithRsaPublicKey(args: parametersOfEncrypt): Promise<string>;
10
+ decryptStringWithRsaPrivateKey(args: parametersOfDecrypt): Promise<string>;
11
+ encrypt(args: parametersOfEncryptPrivate): Promise<string>;
12
+ decrypt(args: parametersOfDecryptPublic): Promise<string>;
13
+ createPrivateAndPublicKeys(modulusLength?: number): Promise<returnCreateKeys>;
14
+ encryptBufferWithRsaPublicKey(buffer: Uint8Array, publicKey?: string): Promise<string>;
15
+ decryptBufferWithRsaPrivateKey(encryptedText: string, privateKey?: string): Promise<Uint8Array>;
16
+ }
17
+ export default NodeRSA;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /**
18
+ * Web build: NodeRSA using Web Crypto API (async).
19
+ * Same interface as Node build; uses crypto.subtle for RSA-OAEP.
20
+ */
21
+ var convertKetToBase64_1 = __importDefault(require("./convertKetToBase64"));
22
+ var crypto_1 = require("./crypto");
23
+ var NodeRSA = /** @class */ (function () {
24
+ function NodeRSA(publicKey, privateKey, modulusLength) {
25
+ this.keyBase64 = 'base64';
26
+ this.publicKey = publicKey;
27
+ this.privateKey = privateKey;
28
+ this.modulusLength = modulusLength !== null && modulusLength !== void 0 ? modulusLength : 2048;
29
+ }
30
+ NodeRSA.prototype.encryptStringWithRsaPublicKey = function (args) {
31
+ var _a = args.publicKey, publicKey = _a === void 0 ? this.publicKey : _a;
32
+ return (0, crypto_1.encryptStringWithRsaPublicKey)(__assign(__assign({}, args), { publicKey: (0, convertKetToBase64_1.default)(publicKey) }));
33
+ };
34
+ NodeRSA.prototype.decryptStringWithRsaPrivateKey = function (args) {
35
+ var _a = args.privateKey, privateKey = _a === void 0 ? this.privateKey : _a;
36
+ return (0, crypto_1.decryptStringWithRsaPrivateKey)(__assign(__assign({}, args), { privateKey: (0, convertKetToBase64_1.default)(privateKey) }));
37
+ };
38
+ NodeRSA.prototype.encrypt = function (args) {
39
+ var _a = args.privateKey, privateKey = _a === void 0 ? this.privateKey : _a;
40
+ return (0, crypto_1.encryptPrivate)(__assign(__assign({}, args), { privateKey: (0, convertKetToBase64_1.default)(privateKey) }));
41
+ };
42
+ NodeRSA.prototype.decrypt = function (args) {
43
+ var _a = args.publicKey, publicKey = _a === void 0 ? this.publicKey : _a;
44
+ return (0, crypto_1.decryptPublic)(__assign(__assign({}, args), { publicKey: (0, convertKetToBase64_1.default)(publicKey) }));
45
+ };
46
+ NodeRSA.prototype.createPrivateAndPublicKeys = function (modulusLength) {
47
+ if (modulusLength === void 0) { modulusLength = this.modulusLength; }
48
+ return (0, crypto_1.createPrivateAndPublicKeys)(modulusLength);
49
+ };
50
+ NodeRSA.prototype.encryptBufferWithRsaPublicKey = function (buffer, publicKey) {
51
+ if (this.keyBase64 !== 'base64') {
52
+ throw new Error('Only base64 encoding is supported');
53
+ }
54
+ var bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
55
+ var binary = '';
56
+ for (var i = 0; i < bytes.length; i++) {
57
+ binary += String.fromCharCode(bytes[i]);
58
+ }
59
+ var base64String = btoa(binary);
60
+ return this.encryptStringWithRsaPublicKey({ text: base64String, publicKey: publicKey });
61
+ };
62
+ NodeRSA.prototype.decryptBufferWithRsaPrivateKey = function (encryptedText, privateKey) {
63
+ if (this.keyBase64 !== 'base64') {
64
+ throw new Error('Only base64 encoding is supported');
65
+ }
66
+ return this.decryptStringWithRsaPrivateKey({ text: encryptedText, privateKey: privateKey }).then(function (decryptedBase64) {
67
+ var binary = atob(decryptedBase64);
68
+ var bytes = new Uint8Array(binary.length);
69
+ for (var i = 0; i < binary.length; i++) {
70
+ bytes[i] = binary.charCodeAt(i);
71
+ }
72
+ return bytes;
73
+ });
74
+ };
75
+ return NodeRSA;
76
+ }());
77
+ exports.default = NodeRSA;
package/package.json CHANGED
@@ -1,19 +1,33 @@
1
1
  {
2
2
  "name": "encrypt-rsa",
3
- "version": "3.2.0",
3
+ "version": "4.0.0",
4
4
  "description": "This is a little module use to encrypt and decrypt strings with RSA keys (public and private keys)",
5
- "main": "./build/index.js",
6
- "module": "./build/index.js",
5
+ "main": "./build/node/node/index.js",
6
+ "module": "./build/node/node/index.js",
7
+ "browser": "./build/web/web/index.js",
8
+ "types": "./build/node/node/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "node": "./build/node/node/index.js",
13
+ "default": "./build/web/web/index.js"
14
+ },
15
+ "require": {
16
+ "node": "./build/node/node/index.js",
17
+ "default": "./build/web/web/index.js"
18
+ }
19
+ }
20
+ },
7
21
  "files": [
8
- "build/**/*"
22
+ "build/node/**/*",
23
+ "build/web/**/*"
9
24
  ],
10
- "types": "./build/index.d.ts",
11
- "source": "./src/index.ts",
25
+ "source": "./src/node/index.ts",
12
26
  "scripts": {
13
27
  "test": "mocha -r ts-node/register tests/**/*.spec.ts",
14
28
  "depcheck": "npm-check -u",
15
29
  "prepare": "husky install",
16
- "build": "tsc",
30
+ "build": "tsc -p tsconfig.node.json && tsc -p tsconfig.web.json",
17
31
  "commit": "git-cz",
18
32
  "docs:serve": "docsify serve docs",
19
33
  "_postinstall": "husky install",
@@ -22,6 +36,8 @@
22
36
  "prepublish": "npm run build",
23
37
  "husky": "husky",
24
38
  "lint": "eslint",
39
+ "docs": "npx @compodoc/compodoc -p tsconfig.doc.json -d docs",
40
+ "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
25
41
  "release": "standard-version"
26
42
  },
27
43
  "devDependencies": {
@@ -32,6 +48,7 @@
32
48
  "@typescript-eslint/parser": "^5.27.0",
33
49
  "chai": "^4.3.4",
34
50
  "commitizen": "^4.2.4",
51
+ "conventional-changelog-cli": "^4.1.0",
35
52
  "cz-conventional-changelog": "^3.3.0",
36
53
  "docsify-cli": "^4.4.3",
37
54
  "eslint": "^8.16.0",
@@ -1,2 +0,0 @@
1
- export declare function convertKetToBase64(key: string): string;
2
- export default convertKetToBase64;
@@ -1,3 +0,0 @@
1
- import { returnCreateKeys } from '../utils/types';
2
- export declare function createPrivateAndPublicKeys(modulusLength?: number): returnCreateKeys;
3
- export default createPrivateAndPublicKeys;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.createPrivateAndPublicKeys = void 0;
27
- var crypto = __importStar(require("crypto"));
28
- function createPrivateAndPublicKeys(modulusLength) {
29
- if (modulusLength === void 0) { modulusLength = 2048; }
30
- if (typeof crypto.generateKeyPairSync === 'function') {
31
- var _a = crypto.generateKeyPairSync('rsa', {
32
- modulusLength: modulusLength,
33
- publicKeyEncoding: {
34
- type: 'spki',
35
- format: 'pem',
36
- },
37
- privateKeyEncoding: {
38
- type: 'pkcs8',
39
- format: 'pem',
40
- },
41
- }), privateKey = _a.privateKey, publicKey = _a.publicKey;
42
- return { publicKey: publicKey, privateKey: privateKey };
43
- }
44
- return { privateKey: '', publicKey: '' };
45
- }
46
- exports.createPrivateAndPublicKeys = createPrivateAndPublicKeys;
47
- exports.default = createPrivateAndPublicKeys;
@@ -1,3 +0,0 @@
1
- import { parametersOfDecryptPublic } from '../utils/types';
2
- export declare function decrypt(args: parametersOfDecryptPublic): string;
3
- export default decrypt;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.decrypt = void 0;
27
- var crypto = __importStar(require("crypto"));
28
- var helpers_1 = require("../utils/helpers");
29
- function decrypt(args) {
30
- var text = args.text, publicKey = args.publicKey;
31
- var publicKeyDecoded = (0, helpers_1.decode)(publicKey);
32
- var buffer = Buffer.from(text, 'base64');
33
- var decrypted = crypto.publicDecrypt(publicKeyDecoded, buffer);
34
- return decrypted.toString('utf8');
35
- }
36
- exports.decrypt = decrypt;
37
- exports.default = decrypt;
@@ -1,3 +0,0 @@
1
- import { parametersOfDecrypt } from '../utils/types';
2
- export declare function decryptStringWithRsaPrivateKey(args: parametersOfDecrypt): string;
3
- export default decryptStringWithRsaPrivateKey;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.decryptStringWithRsaPrivateKey = void 0;
27
- var crypto = __importStar(require("crypto"));
28
- var helpers_1 = require("../utils/helpers");
29
- function decryptStringWithRsaPrivateKey(args) {
30
- var text = args.text, privateKey = args.privateKey;
31
- var privateKeyDecoded = (0, helpers_1.decode)(privateKey);
32
- var buffer = Buffer.from(text, 'base64');
33
- var decrypted = crypto.privateDecrypt(privateKeyDecoded, buffer);
34
- return decrypted.toString('utf8');
35
- }
36
- exports.decryptStringWithRsaPrivateKey = decryptStringWithRsaPrivateKey;
37
- exports.default = decryptStringWithRsaPrivateKey;
@@ -1,3 +0,0 @@
1
- import { parametersOfEncryptPrivate } from '../utils/types';
2
- export declare function encrypt(args: parametersOfEncryptPrivate): string;
3
- export default encrypt;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.encrypt = void 0;
27
- var crypto = __importStar(require("crypto"));
28
- var helpers_1 = require("../utils/helpers");
29
- function encrypt(args) {
30
- var text = args.text, privateKey = args.privateKey;
31
- var privateKeyDecoded = (0, helpers_1.decode)(privateKey);
32
- var buffer = Buffer.from(text);
33
- var encrypted = crypto.privateEncrypt(privateKeyDecoded, buffer);
34
- return encrypted.toString('base64');
35
- }
36
- exports.encrypt = encrypt;
37
- exports.default = encrypt;
@@ -1,3 +0,0 @@
1
- import { parametersOfEncrypt } from '../utils/types';
2
- export declare function encryptStringWithRsaPublicKey(args: parametersOfEncrypt): string;
3
- export default encryptStringWithRsaPublicKey;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.encryptStringWithRsaPublicKey = void 0;
27
- var crypto = __importStar(require("crypto"));
28
- var helpers_1 = require("../utils/helpers");
29
- function encryptStringWithRsaPublicKey(args) {
30
- var text = args.text, publicKey = args.publicKey;
31
- var publicKeyDecoded = (0, helpers_1.decode)(publicKey);
32
- var buffer = Buffer === null || Buffer === void 0 ? void 0 : Buffer.from(text);
33
- var encrypted = crypto === null || crypto === void 0 ? void 0 : crypto.publicEncrypt(publicKeyDecoded, buffer);
34
- return encrypted.toString('base64');
35
- }
36
- exports.encryptStringWithRsaPublicKey = encryptStringWithRsaPublicKey;
37
- exports.default = encryptStringWithRsaPublicKey;
@@ -1,5 +0,0 @@
1
- export * from './createPrivateAndPublicKeys';
2
- export * from './decrypt';
3
- export * from './decryptStringWithRsaPrivateKey';
4
- export * from './encrypt';
5
- export * from './encryptStringWithRsaPublicKey';
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./createPrivateAndPublicKeys"), exports);
18
- __exportStar(require("./decrypt"), exports);
19
- __exportStar(require("./decryptStringWithRsaPrivateKey"), exports);
20
- __exportStar(require("./encrypt"), exports);
21
- __exportStar(require("./encryptStringWithRsaPublicKey"), exports);
package/build/index.d.ts DELETED
@@ -1,17 +0,0 @@
1
- /// <reference types="node" />
2
- import { parametersOfDecrypt, parametersOfDecryptPublic, parametersOfEncrypt, parametersOfEncryptPrivate, returnCreateKeys } from './utils/types';
3
- declare class NodeRSA {
4
- private publicKey;
5
- private privateKey;
6
- private modulusLength;
7
- private keyBase64;
8
- constructor(publicKey?: string, privateKey?: string, modulusLength?: number);
9
- encryptStringWithRsaPublicKey(args: parametersOfEncrypt): string;
10
- decryptStringWithRsaPrivateKey(args: parametersOfDecrypt): string;
11
- encrypt(args: parametersOfEncryptPrivate): string;
12
- decrypt(args: parametersOfDecryptPublic): string;
13
- createPrivateAndPublicKeys(modulusLength?: number): returnCreateKeys;
14
- encryptBufferWithRsaPublicKey(buffer: Buffer, publicKey?: string): string;
15
- decryptBufferWithRsaPrivateKey(encryptedText: string, privateKey?: string): Buffer;
16
- }
17
- export default NodeRSA;
@@ -1,2 +0,0 @@
1
- export declare const decode: (str: string) => string;
2
- export declare const encode: (str: string) => string;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encode = exports.decode = void 0;
4
- var decode = function (str) {
5
- try {
6
- return Buffer.from(str, 'base64').toString('utf-8');
7
- }
8
- catch (error) {
9
- throw new Error('Failed to decode base64 string');
10
- }
11
- };
12
- exports.decode = decode;
13
- var encode = function (str) {
14
- try {
15
- return Buffer.from(str, 'utf-8').toString('base64');
16
- }
17
- catch (error) {
18
- throw new Error('Failed to encode string to base64');
19
- }
20
- };
21
- exports.encode = encode;
@@ -1,20 +0,0 @@
1
- export type returnCreateKeys = {
2
- privateKey: string;
3
- publicKey: string;
4
- };
5
- export type parametersOfEncrypt = {
6
- text: string;
7
- publicKey?: string;
8
- };
9
- export type parametersOfDecrypt = {
10
- text: string;
11
- privateKey?: string;
12
- };
13
- export type parametersOfEncryptPrivate = {
14
- text: string;
15
- privateKey?: string;
16
- };
17
- export type parametersOfDecryptPublic = {
18
- text: string;
19
- publicKey?: string;
20
- };
File without changes