Platforms to show: All Mac Windows Linux Cross-Platform
Back to CCCryptorMBS class.
CCCryptorMBS.Crypt(Operation as Integer, Algorithm as Integer, Options as Integer, key as Ptr, KeyLength as UInt64, IV as Ptr, DataIn as Ptr, DataInLength as UInt64, DataOut as Ptr, DataOutAvailable as UInt64, byref DataOutMoved as UInt64) as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Encryption and Hash | MBS MacOSX Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
This basically performs a sequence of Constructor, Update, Final and Destructor.
Parameters:
Operation | Defines the basic operation: kCCEncrypt or kCCDecrypt. |
Algorithm | Defines the encryption algorithm. |
Options | A word of flags defining options. See kCCOption constants. |
Key | Raw key material, length keyLength bytes. |
keyLength | Length of key material. Must be appropriate for the select algorithm. Some algorithms may provide for varying key lengths. |
IV | Initialization vector, optional. Used for Cipher Block Chaining (CBC) mode. If present, must be the same length as the selected algorithm's block size. If CBC mode is selected (by the absence of any mode bits in the options flags) and no IV is present, a nil (all zeroes) IV will be used. This is ignored if ECB mode is used or if a stream cipher algorithm is selected. |
dataIn | Data to encrypt or decrypt, length dataInLength bytes. |
dataInLength | Length of data to encrypt or decrypt. |
dataOut | Result is written here. Allocated by caller. Encryption and decryption can be performed "in-place", with the same buffer used for input and output. |
dataOutAvailable | The size of the dataOut buffer in bytes. |
dataOutMoved | On successful return, the number of bytes written to dataOut. If kCCBufferTooSmall is returned as a result of insufficient buffer space being provided, the required buffer space is returned here. |
Possible errors in lasterror:
kCCBufferTooSmall indicates insufficent space in the dataOut buffer. In this case, the dataOutMoved parameter will indicate the size of the buffer needed to complete the operation. The operation can be retried with minimal runtime penalty.
kCCAlignmentError indicates that dataInLength was not properly aligned. This can only be returned for block ciphers, and then only when decrypting or when encrypting with block with padding disabled.
kCCDecodeError | Indicates improperly formatted ciphertext or a "wrong key" error; occurs only during decrypt operations. |
See also:
CCCryptorMBS.Crypt(Operation as Integer, Algorithm as Integer, Options as Integer, key as string, IV as Ptr, DataIn as string, byref DataOut as string) as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Encryption and Hash | MBS MacOSX Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
This basically performs a sequence of Constructor, Update, Final and Destructor. This is the convenience function for Xojo with using strings instead of data pointers.
Parameters:
Operation | Defines the basic operation: kCCEncrypt or kCCDecrypt. |
Algorithm | Defines the encryption algorithm. |
Options | A word of flags defining options. See kCCOption constants. |
Key | Raw Key. |
IV | Initialization vector, optional. Used for Cipher Block Chaining (CBC) mode. If present, must be the same length as the selected algorithm's block size. If CBC mode is selected (by the absence of any mode bits in the options flags) and no IV is present, a nil (all zeroes) IV will be used. This is ignored if ECB mode is used or if a stream cipher algorithm is selected. |
dataIn | Data to encrypt or decrypt. |
dataOut | Result is written here. |
Possible errors in lasterror:
kCCBufferTooSmall indicates insufficent space in the dataOut buffer. In this case, the dataOutMoved parameter will indicate the size of the buffer needed to complete the operation. The operation can be retried with minimal runtime penalty.
kCCAlignmentError indicates that dataInLength was not properly aligned. This can only be returned for block ciphers, and then only when decrypting or when encrypting with block with padding disabled.
kCCDecodeError | Indicates improperly formatted ciphertext or a "wrong key" error; occurs only during decrypt operations. |
See also:
CCCryptorMBS.RandomGenerateBytes(data as MemoryBlock) as integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Encryption and Hash | MBS MacOSX Plugin | 21.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The PRNG returns cryptographically strong random bits suitable for use as cryptographic keys, IVs, nonces etc.
Return kCCSuccess on success.
The items on this page are in the following plugins: MBS MacOSX Plugin.