Encrypt
Encrypt content for an address public key using the .encrypt() function.
Returns
This will return the encrypted content.
Usage
Required parameters
Parameter | Description |
---|---|
public_key** ** - string | Public key used for encrypting the content |
content** ** | Content to encrypt |
Optional parameters
In addition to the required parameters above, an object of optional parameters can be passed following the content like so:
encryption.encrypt(public_key, content,
{as_hex: false}
)
as_hex - boolean
Default: true
If true, the function will return the encrypted result as a hexadecimal string representation.
as_string - boolean
Default: true
Should be set to true if the content to encrypt is a string.
curve - string:
secp256k1
orsecp256r1
ored25519
Default "secp256k1"
The curve of encryption, as it can't be deducted from the public key. `` Value can be either
secp256k1
orsecp256r1
ored25519
Using the as_hex
and as_string
options are useful if you want to serialize yourself, or avoid serialization, and if you are working with files (or binary blobs).
Typically, if you want to store an encrypted file, you will handle Buffer objects, and won't serialize in any way (both options will be set to false).
Example
Last updated