Skip to content

libsodium.SKI.EncryptData

Andrew Lambert edited this page Nov 26, 2022 · 8 revisions

libsodium.SKI.EncryptData

Method Signature

 Protected Function EncryptData(ClearText As MemoryBlock, Key As libsodium.SKI.SecretKey, Nonce As MemoryBlock, Exportable As Boolean = False) As MemoryBlock

Parameters

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.

Return value

The encrypted ClearText prepended with a Poly1305 message authentication code, or Nil on error.

Remarks

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.

See also

Clone this wiki locally