Qore's cryptography support is provided by the OpenSSL library. Most of the encryption and decryption functions in this section accept an optional initialization vector, which is data used as initial input for the first block in chained encryption algorithms. Subsequent blocks take input from the last block encrypted/decrypted. If a function accepts an initialization vector and one is not supplied, then a default value of 8 zero bytes will be used.
Some functions require fixed-length keys, and some allow the use of variable-length keys. For functions requiring fixed-length keys any excess bytes are ignored. The same applies to initialization vector arguments.
The following is an example of a function that uses /dev/random to read in a random key for use with encryption functions:
# read a key from /dev/random and return the key sub get_key($size) { # throw an exception if an invalid key size was passed if (!$size || $size < 0) throw "GET-KEY-ERROR", sprintf("invalid size = %n", $size); my $f = new File(); # File::open2() will throw an exception if /dev/random cannot be opened for reading $f.open2("/dev/random"); return $f.readBinary($size); }
Encrypts data using the Cipher Block Chaining function for the blowfish algorithm using a variable-length key and an optional initialization vector. Returns a binary object of the encrypted data.
blowfish_encrypt_cbc(input_data, key, [init_vector]
)
$bin = blowfish_encrypt_cbc("hello there", $key);
Table 3.150. Arguments and Return Values for blowfish_encrypt_cbc()
Argument Type | Return Type | Description |
---|---|---|
String | Binary, String Binary, [String | Binary] | Binary | Encrypts data using the Cipher Block Chaining function for the blowfish algorithm; accepts a variable-length key (recommended 16-bytes or more). The initialization vector must be at least 8 bytes long if present. |
Table 3.151. Exceptions thrown by blowfish_encrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data using the Cipher Block Chaining function for the blowfish algorithm using a variable-length key. This function returns a binary object, for an equivalent function that decrypts to a string, see blowfish_decrypt_cbc_to_string().
blowfish_decrypt_cbc(binary, key, [init_vector]
)
$bin = blowfish_decrypt_cbc("hello there", $key);
Table 3.152. Arguments and Return Values for blowfish_decrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, String | Binary, [String | Binary] |
Binary |
Decrypts data using the Cipher Block Chaining function for the blowfish algorithm using a variable-length key. |
Table 3.153. Exceptions thrown by blowfish_decrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data to a string using the Cipher Block Chaining function for the blowfish algorithm using a variable-length key. This function returns a string, for an equivalent function that decrypts to a binary object, see blowfish_decrypt_cbc().
blowfish_decrypt_cbc_to_string(binary, key, [init_vector]
)
$str = blowfish_decrypt_cbc_to_string($bin, $key);
Table 3.154. Arguments and Return Values for blowfish_decrypt_cbc_to_string()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, Key, [init_vector] |
String |
Decrypts data to a string using the Cipher Block Chaining function for the blowfish algorithm using a variable-length key. |
Table 3.155. Exceptions thrown by blowfish_decrypt_cbc_to_string()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Encrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key. Returns a binary object of the encrypted data.
des_encrypt_cbc(input_data, key, [init_vector]
)
$bin = des_encrypt_cbc($text, $key);
Table 3.156. Arguments and Return Values for des_encrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
String | Binary, String | Binary, [String | Binary] |
Binary |
Encrypts data using the Cipher Block Chaining function for the DES algorithm. The key must be at least 8-bytes long (only the first 8 bytes will be used). If the init_vector is present it must also be at least 8 bytes long. |
Table 3.157. Exceptions thrown by des_encrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8 byte key. This function returns a binary object, for an equivalent function that decrypts to a string, see des_decrypt_cbc_to_string().
des_decrypt_cbc(binary, key, [init_vector]
)
Table 3.158. Arguments and Return Values for des_decrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, String | Binary, [String | Binary] |
Binary |
Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key. If the init_vector is present it must also be at least 8 bytes long. |
Table 3.159. Exceptions thrown by des_decrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key. This function returns a string, for an equivalent function that decrypts to a binary object, see des_decrypt_cbc().
des_decrypt_cbc_to_string(binary, key, [init_vector]
)
Table 3.160. Arguments and Return Values for des_decrypt_cbc_to_string()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, Key, [init_vector] |
String |
Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key. If the init_vector is present it must also be at least 8 bytes long. |
Table 3.161. Exceptions thrown by des_decrypt_cbc_to_string()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Encrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm using two eight-byte keys (set by a single 16-byte key argument). Returns a binary object of the encrypted data.
des_ede_encrypt_cbc(input_data, key, [init_vector]
)
$bin = des_ede_encrypt_cbc($text, $key);
Table 3.162. Arguments and Return Values for des_ede_encrypt_cbc()
Argument Type | Return Type | Description |
---|---|---|
String | Binary |
Binary |
Encrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm. The key argument must be at least 16 bytes long; only the first 16 bytes of the key argument will be used for the two 8-byte keys. If the init_vector argument is present, it must be at least 8 bytes long. |
Table 3.163. Exceptions thrown by des_ede_encrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm using two eight-byte keys (set by a single 16-byte key argument). This function returns a binary object, for an equivalent function that decrypts to a string, see des_ede_decrypt_cbc_to_string().
des_ede_decrypt_cbc(binary, key, [init_vector]
)
$bin = des_ede_decrypt_cbc($data, $key);
Table 3.164. Arguments and Return Values for des_ede_decrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, String | Binary, [String | Binary] |
Binary |
Decrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm. The key argument must be at least 16 bytes long; only the first 16 bytes of the key argument will be used for the two 8-byte keys. If the init_vector argument is present, it must be at least 8 bytes long. |
Table 3.165. Exceptions thrown by des_ede_decrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data to a string using the Cipher Block Chaining function for the two-key triple DES algorithm using two eight-byte keys (set by a single 16-byte key argument). This function returns a string, for an equivalent function that decrypts to a binary object, see des_ede_decrypt_cbc().
des_ede_decrypt_cbc_to_string(binary, key, [init_vector]
)
$str = des_ede_decrypt_cbc_to_string($data, $key);
Table 3.166. Arguments and Return Values for des_ede_decrypt_cbc_to_string()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, String | Binary, [String | Binary] |
String |
Decrypts data to a string using the Cipher Block Chaining function for the two-key triple DES algorithm. The key argument must be at least 16 bytes long; only the first 16 bytes of the key argument will be used for the two 8-byte keys. If the init_vector argument is present, it must be at least 8 bytes long. |
Table 3.167. Exceptions thrown by des_ede_decrypt_cbc_to_string()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Encrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm using three 8-byte keys (set by a single 24-byte key argument) and an optional 8-byte initialization vector. Returns a binary object of the encrypted data.
des_ede3_encrypt_cbc(data, key, [init_vector]
)
$bin = des_ede3_encrypt_cbc($data, $key);
Table 3.168. Arguments and Return Values for des_ede3_encrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
String | Binary, String | Binary, [String | Binary] |
Binary |
Encrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm using three 8-byte keys (set by a single 24-byte key argument) and an optional 8-byte initialization vector. Returns a binary object of the encrypted data. |
Table 3.169. Exceptions thrown by des_ede3_encrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm using three 8-byte keys (set by a single 24-byte key argument) and an optional 8-byte initialization vector. This function returns a binary object, for an equivalent function that decrypts to a string, see des_ede3_decrypt_cbc_to_string().
des_ede3_decrypt_cbc(encrypted_data, key, [init_vector]
)
$bin = des_ede3_decrypt_cbc($data, $key);
Table 3.170. Arguments and Return Values for des_ede3_decrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, Key, [init_vector] |
Binary |
Decrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm. |
Table 3.171. Exceptions thrown by des_ede3_decrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data to a string using the Cipher Block Chaining function for the three-key triple DES algorithm using three 8-byte keys (set by a single 24-byte key argument) and an optional 8-byte initialization vector. This function returns a string, for an equivalent function that decrypts to a binary object, see des_ede3_decrypt_cbc().
des_ede3_decrypt_cbc_to_string(encrypted_data, key, [init_vector]
)
$str = des_ede3_decrypt_cbc_to_string($data, $key);
Table 3.172. Arguments and Return Values for des_ede3_decrypt_cbc_to_string()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, String | Binary, [String | Binary] |
String |
Decrypts data to a string using the Cipher Block Chaining function for the three-key triple DES algorithm using three 8-byte keys (set by a single 24-byte key argument) and an optional 8-byte initialization vector. |
Table 3.173. Exceptions thrown by des_ede3_decrypt_cbc_to_string()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Encrypts data using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key and an optional 8-byte initialization vector. Returns a binary object of the encrypted data.
desx_encrypt_cbc(data, key, [init_vector]
)
$bin = desx_encrypt_cbc($data, $key);
Table 3.174. Arguments and Return Values for desx_encrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
String | Binary, String | Binary, [String | Binary] |
Binary |
Encrypts data using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key and an optional 8-byte initialization vector. |
Table 3.175. Exceptions thrown by desx_encrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key and an optional 8-byte initialization vector. This function returns a binary object, for an equivalent function that decrypts to a string, see desx_decrypt_cbc_to_string().
desx_decrypt_cbc(encrypted_data, key, [init_vector]
)
$bin = desx_decrypt_cbc($data, $key);
Table 3.176. Arguments and Return Values for desx_decrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, Key, [init_vector] |
Binary |
Decrypts data using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key and an optional 8-byte initialization vector. |
Table 3.177. Exceptions thrown by desx_decrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data to a string using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key and an optional 8-byte initialization vector. This function returns a string, for an equivalent function that decrypts to a binary object, see desx_decrypt_cbc().
desx_decrypt_cbc_to_string(binary, key, [init_vector]
)
$str = desx_decrypt_cbc_to_string($data, $key);
Table 3.178. Arguments and Return Values for desx_decrypt_cbc_to_string()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, String 7 Binary, [String | Binary] |
String |
Decrypts data to a string using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key and an optional 8-byte initialization vector. |
Table 3.179. Exceptions thrown by desx_decrypt_cbc_to_string()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Encrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. Returns a binary object of the encrypted data.
rc2_encrypt_cbc(data, key, [init_vector]
)
$bin = rc2_encrypt_cbc($data, $key);
Table 3.180. Arguments and Return Values for rc2_encrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
String | Binary, String | Binary, [String | Binary] |
Binary |
Encrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. |
Table 3.181. Exceptions thrown by rc2_encrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a binary object, for an equivalent function that decrypts to a string, see rc2_decrypt_cbc_to_string().
rc2_decrypt_cbc(encrypted_data, key, [init_vector]
)
$bin = rc2_decrypt_cbc($data, $key);
Table 3.182. Arguments and Return Values for rc2_decrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, String | Binary, [String | Binary] |
Binary |
Decrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. |
Table 3.183. Exceptions thrown by rc2_decrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data to a string using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a string, for an equivalent function that decrypts to a binary object, see rc2_decrypt_cbc().
rc2_decrypt_cbc_to_string(encrypted_data, key, [init_vector]
)
$str = rc2_decrypt_cbc_to_string($data, $key);
Table 3.184. Arguments and Return Values for rc2_decrypt_cbc_to_string()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, String | Binary, [String | Binary] |
String |
Decrypts data to a string using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. |
Table 3.185. Exceptions thrown by rc2_decrypt_cbc_to_string()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Encrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector. Returns a binary object of the encrypted data.
cast5_encrypt_cbc(data, key, [init_vector]
)
$bin = cast5_encrypt_cbc($data, $key);
Table 3.186. Arguments and Return Values for cast5_encrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
String | Binary, String | Binary, [String | Binary] |
Binary |
Encrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector. |
Table 3.187. Exceptions thrown by cast5_encrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a binary object, for an equivalent function that decrypts to a string, see cast5_decrypt_cbc_to_string().
cast5_decrypt_cbc(encrypted_data, key, [init_vector]
)
$bin = cast5_decrypt_cbc($data, $key);
Table 3.188. Arguments and Return Values for cast5_decrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, Key, [init_vector] |
Binary |
Decrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector. |
Table 3.189. Exceptions thrown by cast5_decrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data to a string using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a string, for an equivalent function that decrypts to a binary object, see cast5_decrypt_cbc().
cast5_decrypt_cbc_to_string(binary, key, [init_vector]
)
$str = cast5_decrypt_cbc_to_string($data, $key);
Table 3.190. Arguments and Return Values for cast5_decrypt_cbc_to_string()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, Key, [init_vector] |
String |
Decrypts data to a string using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector. |
Table 3.191. Exceptions thrown by cast5_decrypt_cbc_to_string()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Encrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. Returns a binary object of the encrypted data.
rc4_encrypt(data, key, [init_vector]
)
$bin = rc4_encrypt($data, $key);
Table 3.192. Arguments and Return Values for rc4_encrypt()
Argument Type |
Return Type |
Description |
---|---|---|
String | Binary, String | Binary, [String | Binary, ] |
Binary |
Encrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. |
Table 3.193. Exceptions thrown by rc4_encrypt()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a binary object, for an equivalent function that decrypts to a string, see rc4_decrypt_to_string().
rc4_decrypt(binary, key, [init_vector]
)
$bin = rc4_decrypt($data, $key);
Table 3.194. Arguments and Return Values for rc4_decrypt()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, Key, [init_vector] |
Binary |
Decrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. |
Table 3.195. Exceptions thrown by rc4_decrypt()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Decrypts data to a string using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a string, for an equivalent function that decrypts to a binary object, see rc4_decrypt().
rc4_decrypt_to_string(binary, key, [init_vector]
)
$str = rc4_decrypt_to_string($data, $key);
Table 3.196. Arguments and Return Values for rc4_decrypt_to_string()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, Key, [init_vector] |
String |
Decrypts data to a string using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. |
Table 3.197. Exceptions thrown by rc4_decrypt_to_string()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
Encrypts data using the Cipher Block Chaining function for RSA's RC5(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. Returns a binary object of the encrypted data. The availability of this function depends on the availability of the RC5 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_RC5
before running this function. See Library Option Constants for a list of all option constants.
rc5_encrypt_cbc(data, key, [init_vector]
)
$bin = rc5_encrypt_cbc($data, $key);
Table 3.198. Arguments and Return Values for rc5_encrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
String | Binary, String | Binary, [String | Binary] |
Binary |
Encrypts data using the Cipher Block Chaining function for RSA's RC5(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. |
Table 3.199. Exceptions thrown by rc5_encrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
| This exception is thrown when the function is not available; for maximum portability, check the constant |
Decrypts data using the Cipher Block Chaining function for RSA's RC5(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a binary object, for an equivalent function that decrypts to a string, see rc5_decrypt_cbc_to_string(). The availability of this function depends on the availability of the RC5 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_RC5
before running this function. See Library Option Constants for a list of all option constants.
rc5_decrypt_cbc(binary, key, [init_vector]
)
$bin = rc5_decrypt_cbc($data, $key);
Table 3.200. Arguments and Return Values for rc5_decrypt_cbc()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, Key, [init_vector] |
Binary |
Decrypts data using the Cipher Block Chaining function for RSA's RC5(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. |
Table 3.201. Exceptions thrown by rc5_decrypt_cbc()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
| This exception is thrown when the function is not available; for maximum portability, check the constant |
Decrypts data to a string using the Cipher Block Chaining function for RSA's RC5(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a string, for an equivalent function that decrypts to a binary object, see rc5_decrypt_cbc(). The availability of this function depends on the availability of the RC5 algorithm in the openssl library used to compile the Qore library; for maximum portability check the constant HAVE_RC5
before running this function. See Library Option Constants for a list of all option constants.
rc5_decrypt_cbc_to_string(encrypted_data, key, [init_vector]
)
$str = rc5_decrypt_cbc_to_string($data, $key);
Table 3.202. Arguments and Return Values for rc5_decrypt_cbc_to_string()
Argument Type |
Return Type |
Description |
---|---|---|
Binary, Key, [init_vector] |
String |
Decrypts data to a string using the Cipher Block Chaining function for RSA's RC5(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. |
Table 3.203. Exceptions thrown by rc5_decrypt_cbc_to_string()
err |
desc |
---|---|
|
missing data (string or binary) parameter to function, invalid data type (expecing string or binary) |
|
missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present) |
| This exception is thrown when the function is not available; for maximum portability, check the constant |