Encryption / Decryption
Once you have the user's keys, you can easily encrypt and decrypt messages:
Encrypt
Simply pass the public key of the receiver and the message to obtain the encrypted message.
Parameters description
Parameter | Description | Optional |
---|---|---|
receiverPublicKey | The public key of the receiver, obtained from Ceramic and the user's address | No |
message | Message as Uint8Array or string | No |
toHex | Whether to convert the encrypted message to a hexadecimal string or not. | Yes |
Decrypt
Likewise, pass the public key of the sender and the message to obtain the decrypted message.
Parameters description
Parameter | Description | Optional |
---|---|---|
senderPublicKey | The public key of the sender, obtained from Ceramic and the user's address | No |
message | Encrypted message as Uint8Array or string | No |
Last updated