-
-
Notifications
You must be signed in to change notification settings - Fork 37
rsa.js
- Rsa
-
Provides some methods for the RSA
sha256WithRSAEncryption
withRSA_PKCS1_OAEP_PADDING
.
Provides some methods for the RSA sha256WithRSAEncryption
with RSA_PKCS1_OAEP_PADDING
.
Kind: global class
Alias of the RSA_PKCS1_OAEP_PADDING
mode
Kind: static property of Rsa
Alias of the RSA_PKCS1_PADDING
mode
Kind: static property of Rsa
Encrypts text with sha256WithRSAEncryption/RSA_PKCS1_OAEP_PADDING.
Recommended Node Limits Version >= 12.9.0 (oaepHash
was available), even if it works on v10.15.0.
Kind: static method of Rsa
Returns: string
- Base64-encoded ciphertext.
Throws:
-
RangeError
- While the padding isn'tRSA_PKCS1_OAEP_PADDING
norRSA_PKCS1_PADDING
.
Param | Type | Description |
---|---|---|
plaintext | string |
Cleartext to encode. |
publicKey |
string | Buffer
|
A PEM encoded public certificate. |
padding | number |
Supporting RSA_PKCS1_OAEP_PADDING or RSA_PKCS1_PADDING , default is RSA_PKCS1_OAEP_PADDING . |
Decrypts base64 encoded string with privateKey
.
Recommended Node Limits Version >= 12.9.0 (oaepHash
was available), even if it works on v10.15.0.
Kind: static method of Rsa
Returns: string
- Utf-8 plaintext.
Throws:
-
RangeError
- While the padding isn'tRSA_PKCS1_OAEP_PADDING
norRSA_PKCS1_PADDING
.
Param | Type | Description |
---|---|---|
ciphertext | string |
Was previously encrypted string using the corresponding public certificate. |
privateKey |
string | Buffer
|
A PEM encoded private key certificate. |
padding | number |
Supporting RSA_PKCS1_OAEP_PADDING or RSA_PKCS1_PADDING , default is RSA_PKCS1_OAEP_PADDING . |
Creates and returns a Sign
string that uses sha256WithRSAEncryption
.
Kind: static method of Rsa
Returns: string
- Base64-encoded signature.
Param | Type | Description |
---|---|---|
message |
string | Buffer
|
Content will be crypto.Sign . |
privateKey |
string | Buffer
|
A PEM encoded private key certificate. |
Verifying the message
with given signature
string that uses sha256WithRSAEncryption
.
Kind: static method of Rsa
Returns: boolean
- True is passed, false is failed.
Param | Type | Description |
---|---|---|
message |
string | Buffer
|
Content will be crypto.Verify . |
signature | string |
The base64-encoded ciphertext. |
publicKey |
string | Buffer
|
A PEM encoded public certificate. |
Kind: global function
Throws:
-
RangeError
- While the padding isn'tRSA_PKCS1_OAEP_PADDING
norRSA_PKCS1_PADDING
.
Param | Type | Description |
---|---|---|
code | number |
Supporting RSA_PKCS1_OAEP_PADDING or RSA_PKCS1_PADDING , default is RSA_PKCS1_OAEP_PADDING . |