-
-
Notifications
You must be signed in to change notification settings - Fork 3
libsodium.SKI.EncryptData
Andrew Lambert edited this page Nov 26, 2022
·
8 revisions
Protected Function EncryptData(ClearText As MemoryBlock, Key As libsodium.SKI.SecretKey, Nonce As MemoryBlock, Exportable As Boolean = False) As MemoryBlock
Name | Type | Comment |
---|---|---|
ClearText | MemoryBlock | The data to be encrypted. |
Key | SecretKey | The secret key. |
Nonce | MemoryBlock | The random nonce to be used. |
Exportable | Boolean | Optional. If True then the return value is encoded in a text-based export format; otherwise the raw binary data is returned. |
The encrypted ClearText
prepended with a Poly1305 message authentication code, or Nil
on error.
Encrypts the ClearText
using the XSalsa20 stream cipher with a secret key and a Nonce. A Poly1305 message authentication code is prepended to the returned data, which will be validated by the DecryptData method. On error this method returns Nil
.
If Exportable=True
then the return value is the encrypted message and its nonce encoded in a plain text format. Both the raw binary and plain text format are understood by the DecryptData
method.
- Secret key encryption example
- DecryptData
- Authenticated encryption in the libsodium documentation.
Wiki home | Project page | Bugs | Become a sponsor
Text and code examples are Copyright ©2016-24 Andrew Lambert, offered under the CC BY-SA 3.0 License.