encrypt-rsa 2.0.0 → 2.0.1
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.
- package/CHANGELOG.md +6 -0
- package/README.md +3 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
RSA algorithm is asymmetric cryptography algorithm. Asymmetric actually means that it works on two different keys i.e. Public Key and Private Key. As the name describes that the Public Key is given to everyone and Private key is kept private.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## For more explanation about RSA Algorithm visit [RSA algorithm](https://milad-ezzat.vercel.app/blog/encrypt-by-rsa-algorithm)
|
|
12
12
|
|
|
13
13
|
1. [Installation](#installation)
|
|
14
14
|
2. [Usage](#usage)
|
|
@@ -41,16 +41,12 @@ const nodeRSA = new NodeRSA();
|
|
|
41
41
|
|
|
42
42
|
const { privateKey, publicKey } = nodeRSA.createPrivateAndPublicKeys()
|
|
43
43
|
|
|
44
|
-
// to save your keys
|
|
45
|
-
fs.writeFileSync('./private-key', privateKey);
|
|
46
|
-
fs.writeFileSync('./public-key', publicKey);
|
|
47
|
-
|
|
48
44
|
|
|
49
45
|
// you must have 'public-key' file the key you want to encrypt by it
|
|
50
46
|
|
|
51
47
|
const encryptedText = nodeRSA.encryptStringWithRsaPublicKey({
|
|
52
48
|
text: 'hello',
|
|
53
|
-
|
|
49
|
+
publicKey: public
|
|
54
50
|
});
|
|
55
51
|
|
|
56
52
|
console.log({ encryptedText });
|
|
@@ -63,12 +59,10 @@ console.log({ encryptedText });
|
|
|
63
59
|
|
|
64
60
|
const decryptedText = nodeRSA.decryptStringWithRsaPrivateKey({
|
|
65
61
|
text: encryptedText,
|
|
66
|
-
|
|
62
|
+
privateKey: private
|
|
67
63
|
});
|
|
68
64
|
|
|
69
65
|
console.log({ decryptedText });
|
|
70
66
|
// result: { decryptedText: 'hello' }
|
|
71
67
|
|
|
72
68
|
```
|
|
73
|
-
for more information about RSA:
|
|
74
|
-
[https://simple.wikipedia.org/wiki/RSA_algorithm](https://simple.wikipedia.org/wiki/RSA_algorithm)
|
package/package.json
CHANGED