new PublicKey(keyDer)
Create a new PublicKey by decoding the keyDer. Set the key type from the
decoding.
Parameters:
Name | Type | Description |
---|---|---|
keyDer |
Blob | The blob of the SubjectPublicKeyInfo DER. |
Throws:
UnrecognizedKeyFormatException if can't decode the key DER.
Methods
encrypt(plainData, algorithmType) → {Blob}
Encrypt the plainData using the keyBits according the encrypt algorithm type.
Parameters:
Name | Type | Description |
---|---|---|
plainData |
Blob | Buffer | The data to encrypt. |
algorithmType |
number | The algorithm type from the EncryptAlgorithmType enum, e.g., RsaOaep. |
Throws:
Error If encryptPromise doesn't return a SyncPromise which is
already fulfilled.
Returns:
The encrypted data.
- Type
- Blob
encryptPromise(plainData, algorithmType, useSync) → {Promise|SyncPromise}
Encrypt the plainData using the keyBits according the encrypt algorithm type.
Parameters:
Name | Type | Description |
---|---|---|
plainData |
Blob | Buffer | The data to encrypt. |
algorithmType |
number | The algorithm type from the EncryptAlgorithmType enum, e.g., RsaOaep. |
useSync |
boolean | (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise. |
Returns:
A promise which returns the encrypted Blob.
- Type
- Promise | SyncPromise
getDigest(digestAlgorithm) → {Blob}
Get the digest of the public key.
Parameters:
Name | Type | Description |
---|---|---|
digestAlgorithm |
number | (optional) The integer from DigestAlgorithm, such as DigestAlgorithm.SHA256. If omitted, use DigestAlgorithm.SHA256 . |
Returns:
The digest value.
- Type
- Blob
getKeyDer() → {Blob}
Get the raw bytes of the public key in DER format.
Returns:
The public key DER.
- Type
- Blob
getKeyType() → {number}
Get the key type.
Returns:
The key type as an int from KeyType.
- Type
- number
toDer() → {DerNode}
Encode the public key into DER.
Returns:
The encoded DER syntax tree.
- Type
- DerNode