Qore Programming Language Reference Manual  1.7.0
Cryptographic Functions
Collaboration diagram for Cryptographic Functions:

Modules

 Digest (Hash) Functions
 

Functions

binary Qore::blowfish_decrypt_cbc (binary data, data key, data iv=Qore::DefaultIV)
 Decrypts data using the Cipher Block Chaining function for the blowfish algorithm and returns a binary value of the decrypted data. More...
 
string Qore::blowfish_decrypt_cbc_to_string (binary data, data key, data iv=Qore::DefaultIV, *string encoding)
 Decrypts data using the Cipher Block Chaining function for the blowfish algorithm and returns a string of the decrypted data. More...
 
binary Qore::blowfish_encrypt_cbc (data data, data key, data iv=Qore::DefaultIV)
 Encrypts data using the Cipher Block Chaining function for the blowfish algorithm More...
 
binary Qore::cast5_decrypt_cbc (binary data, data key, data iv=Qore::DefaultIV)
 Decrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector. More...
 
string Qore::cast5_decrypt_cbc_to_string (binary data, data key, data iv=Qore::DefaultIV, *string encoding)
 Decrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector. More...
 
binary Qore::cast5_encrypt_cbc (data data, data key, data iv=Qore::DefaultIV)
 Encrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector. More...
 
binary Qore::des_decrypt_cbc (binary data, data key, data iv=Qore::DefaultIV)
 Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key. More...
 
string Qore::des_decrypt_cbc_to_string (binary data, data key, data iv=Qore::DefaultIV, *string encoding)
 Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key. More...
 
binary Qore::des_ede3_decrypt_cbc (data data, data key, data iv=Qore::DefaultIV)
 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. More...
 
string Qore::des_ede3_decrypt_cbc_to_string (binary data, data key, data iv=Qore::DefaultIV, *string encoding)
 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. More...
 
binary Qore::des_ede3_encrypt_cbc (data data, data key, data iv=Qore::DefaultIV)
 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. More...
 
binary Qore::des_ede_decrypt_cbc (binary data, data key, data iv=Qore::DefaultIV)
 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) More...
 
string Qore::des_ede_decrypt_cbc_to_string (binary data, data key, data iv=Qore::DefaultIV, *string encoding)
 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) More...
 
binary Qore::des_ede_encrypt_cbc (data data, data key, data iv=Qore::DefaultIV)
 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) More...
 
binary Qore::des_encrypt_cbc (data data, data key, data iv=Qore::DefaultIV)
 Encrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key. More...
 
binary Qore::des_random_key ()
 Returns a binary value of a random key for the DES algorithm More...
 
binary Qore::desx_decrypt_cbc (binary data, data key, data iv=Qore::DefaultIV)
 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. More...
 
string Qore::desx_decrypt_cbc_to_string (binary data, data key, data iv=Qore::DefaultIV, *string encoding)
 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. More...
 
binary Qore::desx_encrypt_cbc (data data, data key, data iv=Qore::DefaultIV)
 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. More...
 
binary Qore::rc2_decrypt_cbc (binary data, data key, data iv=Qore::DefaultIV)
 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. More...
 
string Qore::rc2_decrypt_cbc_to_string (binary data, data key, data iv=Qore::DefaultIV, *string encoding)
 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. More...
 
binary Qore::rc2_encrypt_cbc (data data, data key, data iv=Qore::DefaultIV)
 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. More...
 
binary Qore::rc4_decrypt (binary data, data key, data iv=Qore::DefaultIV)
 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. More...
 
string Qore::rc4_decrypt_to_string (binary data, data key, data iv=Qore::DefaultIV, *string encoding)
 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. More...
 
binary Qore::rc4_encrypt (data data, data key, data iv=Qore::DefaultIV)
 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. More...
 
binary Qore::rc5_decrypt_cbc (binary data, data key, data iv=Qore::DefaultIV)
 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. More...
 
string Qore::rc5_decrypt_cbc_to_string (binary data, data key, data iv=Qore::DefaultIV, *string encoding)
 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. More...
 
binary Qore::rc5_encrypt_cbc (data data, data key, data iv=Qore::DefaultIV)
 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. More...
 

Detailed Description

Qore's cryptography support is provided by the OpenSSL library. Each 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 an initialization vector is not supplied, a default value of 8 zero bytes will be used (see Qore::DefaultIV).

See also:

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 on UNIX to read in a random key for use with encryption functions:

# read a key from /dev/random and return the key
binary sub get_key(int size) {
# throw an exception if an invalid key size was passed
if (!size || size < 0) {
throw "GET-KEY-ERROR", sprintf("invalid size = %n", size);
}
File f();
# File::open2() will throw an exception if /dev/random cannot be opened for reading
f.open2("/dev/random");
return f.readBinary(size);
}
string sprintf(string fmt,...)
Returns a formatted string based on a format string and other arguments; does not enforce field width...
Note
The following generic cryptographic functions are recommended over the older cipher-specific functions which will be deprecated in a later release of Qore:

Function Documentation

◆ blowfish_decrypt_cbc()

binary Qore::blowfish_decrypt_cbc ( binary  data,
data  key,
data  iv = Qore::DefaultIV 
)

Decrypts data using the Cipher Block Chaining function for the blowfish algorithm and returns a binary value of the decrypted data.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keya variable-length key (recommended 16 bytes or more)
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the decrypted data
Example:
binary bin = blowfish_decrypt_cbc(data, key);
binary blowfish_decrypt_cbc(binary data, data key, data iv=Qore::DefaultIV)
Decrypts data using the Cipher Block Chaining function for the blowfish algorithm and returns a binar...
Exceptions
BLOWFISH-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_binary(CRYPTO_ALG_BLOWFISH, data, key, iv)
See also
the following generic cryptographic API functions:

◆ blowfish_decrypt_cbc_to_string()

string Qore::blowfish_decrypt_cbc_to_string ( binary  data,
data  key,
data  iv = Qore::DefaultIV,
*string  encoding 
)

Decrypts data using the Cipher Block Chaining function for the blowfish algorithm and returns a string of the decrypted data.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keya variable-length key (recommended 16 bytes or more)
ivthe initialization vector must be at least 8 bytes long if present
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed
Returns
a string of the decrypted data
Example:
string str = blowfish_decrypt_cbc_to_string(data, key, NOTHING, "iso-8859-1");
string blowfish_decrypt_cbc_to_string(binary data, data key, data iv=Qore::DefaultIV, *string encoding)
Decrypts data using the Cipher Block Chaining function for the blowfish algorithm and returns a strin...
Exceptions
BLOWFISH-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_string(CRYPTO_ALG_BLOWFISH, data, key, iv, ...)
See also
the following generic cryptographic API functions:
Since
Qore 0.8.4 added the encoding parameter to specify the output encoding of the string

◆ blowfish_encrypt_cbc()

binary Qore::blowfish_encrypt_cbc ( data  data,
data  key,
data  iv = Qore::DefaultIV 
)

Encrypts data using the Cipher Block Chaining function for the blowfish algorithm

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be encrypted
keya variable-length key (recommended 16 bytes or more)
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the encrypted data
Example:
binary bin = blowfish_encrypt_cbc(data, key);
binary blowfish_encrypt_cbc(data data, data key, data iv=Qore::DefaultIV)
Encrypts data using the Cipher Block Chaining function for the blowfish algorithm
Exceptions
BLOWFISH-ENCRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
ENCRYPT-ERRORprocessing error encrypting the data (should not normally happen)
Note
Equivalent to encrypt(CRYPTO_ALG_BLOWFISH, data, key, iv)
See also
the following generic cryptographic API functions:

◆ cast5_decrypt_cbc()

binary Qore::cast5_decrypt_cbc ( binary  data,
data  key,
data  iv = Qore::DefaultIV 
)

Decrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keya variable-width decryption key
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the decrypted data
Example:
binary bin = cast5_decrypt_cbc(data, key);
binary cast5_decrypt_cbc(binary data, data key, data iv=Qore::DefaultIV)
Decrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-lengt...
Exceptions
CAST5-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_binary(CRYPTO_ALG_CAST5, data, key, iv)
See also
the following generic cryptographic API functions:

◆ cast5_decrypt_cbc_to_string()

string Qore::cast5_decrypt_cbc_to_string ( binary  data,
data  key,
data  iv = Qore::DefaultIV,
*string  encoding 
)

Decrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keya variable-width decryption key
ivthe initialization vector must be at least 8 bytes long if present
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed
Returns
a string of the decrypted data
Example:
string bin = cast5_decrypt_cbc_to_string(data, key, NOTHING, "iso-8859-1");
string cast5_decrypt_cbc_to_string(binary data, data key, data iv=Qore::DefaultIV, *string encoding)
Decrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-lengt...
Exceptions
CAST5-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_string(CRYPTO_ALG_CAST5, data, key, iv)
See also
the following generic cryptographic API functions:
Since
Qore 0.8.4 added the encoding parameter to specify the output encoding of the string

◆ cast5_encrypt_cbc()

binary Qore::cast5_encrypt_cbc ( data  data,
data  key,
data  iv = Qore::DefaultIV 
)

Encrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be encrypted
keya variable-width encryption key
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the encrypted data
Example:
binary bin = cast5_encrypt_cbc(data, key);
binary cast5_encrypt_cbc(data data, data key, data iv=Qore::DefaultIV)
Encrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-lengt...
Exceptions
CAST5-ENCRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
ENCRYPT-ERRORprocessing error encrypting the data (should not normally happen)
Note
Equivalent to encrypt(CRYPTO_ALG_CAST5, data, key, iv)
See also
the following generic cryptographic API functions:

◆ des_decrypt_cbc()

binary Qore::des_decrypt_cbc ( binary  data,
data  key,
data  iv = Qore::DefaultIV 
)

Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keythe decryption key must be at least 8 bytes long (only the first 8 bytes will be used)
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the decrypted data
Example:
binary bin = des_decrypt_cbc(data, key);
binary des_decrypt_cbc(binary data, data key, data iv=Qore::DefaultIV)
Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key.
Exceptions
DES-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DES-KEY-ERRORinvalid key (too short)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_binary(CRYPTO_ALG_DES, data, key, iv)
See also
the following generic cryptographic API functions:

◆ des_decrypt_cbc_to_string()

string Qore::des_decrypt_cbc_to_string ( binary  data,
data  key,
data  iv = Qore::DefaultIV,
*string  encoding 
)

Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keythe decryption key must be at least 8 bytes long (only the first 8 bytes will be used)
ivthe initialization vector must be at least 8 bytes long if present
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed
Returns
a string of the decrypted data
Example:
string bin = des_decrypt_cbc_to_string(data, key, NOTHING, "iso-8859-1");
string des_decrypt_cbc_to_string(binary data, data key, data iv=Qore::DefaultIV, *string encoding)
Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key.
Exceptions
DES-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DES-KEY-ERRORinvalid key (too short)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_binary(CRYPTO_ALG_DES, data, key, iv, ...)
See also
the following generic cryptographic API functions:
Since
Qore 0.8.4 added the encoding parameter to specify the output encoding of the string

◆ des_ede3_decrypt_cbc()

binary Qore::des_ede3_decrypt_cbc ( data  data,
data  key,
data  iv = Qore::DefaultIV 
)

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.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keythe decryption key must be at least 24 bytes long (only the first 24 bytes will be used for the three 8-byte keys)
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the decrypted data
Example:
binary bin = des_ede3_decrypt_cbc(data, key);
binary des_ede3_decrypt_cbc(data data, data key, data iv=Qore::DefaultIV)
Decrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm using t...
Exceptions
DES-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DES-KEY-ERRORinvalid key (too short)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_binary(CRYPTO_ALG_DES_EDE3, data, key, iv)
See also
the following generic cryptographic API functions:

◆ des_ede3_decrypt_cbc_to_string()

string Qore::des_ede3_decrypt_cbc_to_string ( binary  data,
data  key,
data  iv = Qore::DefaultIV,
*string  encoding 
)

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.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keythe decryption key must be at least 24 bytes long (only the first 24 bytes will be used for the three 8-byte keys)
ivthe initialization vector must be at least 8 bytes long if present
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed
Returns
a string of the decrypted data
Example:
string bin = des_ede3_decrypt_cbc_to_string(data, key, NOTHING, "iso-8859-1");
string des_ede3_decrypt_cbc_to_string(binary data, data key, data iv=Qore::DefaultIV, *string encoding)
Decrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm using t...
Exceptions
DES-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DES-KEY-ERRORinvalid key (too short)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_string(CRYPTO_ALG_DES_EDE2, data, key, iv, ...)
See also
the following generic cryptographic API functions:
Since
Qore 0.8.4 added the encoding parameter to specify the output encoding of the string

◆ des_ede3_encrypt_cbc()

binary Qore::des_ede3_encrypt_cbc ( data  data,
data  key,
data  iv = Qore::DefaultIV 
)

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.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be encrypted
keythe encryption key must be at least 24 bytes long (only the first 24 bytes will be used for the three 8-byte keys)
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the encrypted data
Example:
binary bin = des_ede3_encrypt_cbc(data, key);
binary des_ede3_encrypt_cbc(data data, data key, data iv=Qore::DefaultIV)
Encrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm using t...
Exceptions
DES-ENCRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DES-KEY-ERRORinvalid key (too short)
ENCRYPT-ERRORprocessing error encrypting the data (should not normally happen)
Note
Equivalent to encrypt(CRYPTO_ALG_DES_EDE3, data, key, iv)
See also
the following generic cryptographic API functions:

◆ des_ede_decrypt_cbc()

binary Qore::des_ede_decrypt_cbc ( binary  data,
data  key,
data  iv = Qore::DefaultIV 
)

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)

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keythe decryption key must be at least 16 bytes long (only the first 16 bytes will be used for the two 8-byte keys)
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the decrypted data
Example:
binary bin = des_ede_decrypt_cbc(data, key);
binary des_ede_decrypt_cbc(binary data, data key, data iv=Qore::DefaultIV)
Decrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm using two...
Exceptions
DES-ENCRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DES-KEY-ERRORinvalid key (too short)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_binary(CRYPTO_ALG_DES_EDE, data, key, iv)
See also
the following generic cryptographic API functions:

◆ des_ede_decrypt_cbc_to_string()

string Qore::des_ede_decrypt_cbc_to_string ( binary  data,
data  key,
data  iv = Qore::DefaultIV,
*string  encoding 
)

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)

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keythe decryption key must be at least 16 bytes long (only the first 16 bytes will be used for the two 8-byte keys)
ivthe initialization vector must be at least 8 bytes long if present
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed
Returns
a string of the decrypted data
Example:
string bin = des_ede_decrypt_cbc_to_string(data, key, NOTHING, "iso-8859-1");
string des_ede_decrypt_cbc_to_string(binary data, data key, data iv=Qore::DefaultIV, *string encoding)
Decrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm using two...
Exceptions
DES-ENCRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DES-KEY-ERRORinvalid key (too short)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_string(CRYPTO_ALG_DES_EDE, data, key, iv, ...)
See also
the following generic cryptographic API functions:
Since
Qore 0.8.4 added the encoding parameter to specify the output encoding of the string

◆ des_ede_encrypt_cbc()

binary Qore::des_ede_encrypt_cbc ( data  data,
data  key,
data  iv = Qore::DefaultIV 
)

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)

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be encrypted
keythe encryption key must be at least 16 bytes long (only the first 16 bytes will be used for the two 8-byte keys)
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the encrypted data
Example:
binary bin = des_ede_encrypt_cbc(data, key);
binary des_ede_encrypt_cbc(data data, data key, data iv=Qore::DefaultIV)
Encrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm using two...
Exceptions
DES-ENCRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DES-KEY-ERRORinvalid key (too short)
ENCRYPT-ERRORprocessing error encrypting the data (should not normally happen)
Note
Equivalent to encrypt(CRYPTO_ALG_DES_EDE, data, key, iv)
See also
the following generic cryptographic API functions:

◆ des_encrypt_cbc()

binary Qore::des_encrypt_cbc ( data  data,
data  key,
data  iv = Qore::DefaultIV 
)

Encrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be encrypted
keythe encryption key must be at least 8 bytes long (only the first 8 bytes will be used)
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the encrypted data
Example:
binary bin = des_encrypt_cbc(data, key);
binary des_encrypt_cbc(data data, data key, data iv=Qore::DefaultIV)
Encrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key.
Exceptions
DES-ENCRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DES-KEY-ERRORinvalid key (too short)
ENCRYPT-ERRORprocessing error encrypting the data (should not normally happen)
Note
Equivalent to encrypt(CRYPTO_ALG_DES, data, key, iv)
See also
the following generic cryptographic API functions:

◆ des_random_key()

binary Qore::des_random_key ( )

Returns a binary value of a random key for the DES algorithm

Returns
a binary value of a random key for the DES algorithm
Code Flags:
CONSTANT
Example:
binary bin = des_random_key();
binary des_random_key()
Returns a binary value of a random key for the DES algorithm

◆ desx_decrypt_cbc()

binary Qore::desx_decrypt_cbc ( binary  data,
data  key,
data  iv = Qore::DefaultIV 
)

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.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keythe decryption key must be at least 24 bytes long (only the first 24 bytes will be used)
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the decrypted data
Example:
binary bin = desx_decrypt_cbc(data, key);
binary desx_decrypt_cbc(binary data, data key, data iv=Qore::DefaultIV)
Decrypts data using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key a...
Exceptions
DESX-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DESX-KEY-ERRORinvalid key (too short)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_binary(CRYPTO_ALG_DESX, data, key, iv)
See also
the following generic cryptographic API functions:

◆ desx_decrypt_cbc_to_string()

string Qore::desx_decrypt_cbc_to_string ( binary  data,
data  key,
data  iv = Qore::DefaultIV,
*string  encoding 
)

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.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keythe decryption key must be at least 24 bytes long (only the first 24 bytes will be used)
ivthe initialization vector must be at least 8 bytes long if present
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed
Returns
a binary value of the decrypted data
Example:
string str = desx_decrypt_cbc_to_string(data, key, NOTHING, "iso-8859-1");
string desx_decrypt_cbc_to_string(binary data, data key, data iv=Qore::DefaultIV, *string encoding)
Decrypts data using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key a...
Exceptions
DESX-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DESX-KEY-ERRORinvalid key (too short)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_string(CRYPTO_ALG_DESX, data, key, iv, ...)
See also
the following generic cryptographic API functions:
Since
Qore 0.8.4 added the encoding parameter to specify the output encoding of the string

◆ desx_encrypt_cbc()

binary Qore::desx_encrypt_cbc ( data  data,
data  key,
data  iv = Qore::DefaultIV 
)

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.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be encrypted
keythe encryption key must be at least 24 bytes long (only the first 24 bytes will be used)
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the encrypted data
Example:
binary bin = desx_encrypt_cbc(data, key);
binary desx_encrypt_cbc(data data, data key, data iv=Qore::DefaultIV)
Encrypts data using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key a...
Exceptions
DESX-ENCRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DESX-KEY-ERRORinvalid key (too short)
ENCRYPT-ERRORprocessing error encrypting the data (should not normally happen)
Note
Equivalent to encrypt(CRYPTO_ALG_DESX, data, key, iv)
See also
the following generic cryptographic API functions:

◆ rc2_decrypt_cbc()

binary Qore::rc2_decrypt_cbc ( binary  data,
data  key,
data  iv = Qore::DefaultIV 
)

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.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keya variable-width decryption key
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the decrypted data
Example:
binary bin = rc2_decrypt_cbc(data, key);
binary rc2_decrypt_cbc(binary data, data key, data iv=Qore::DefaultIV)
Decrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-l...
Exceptions
RC2-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_binary(CRYPTO_ALG_RC2, data, key, iv)
See also
the following generic cryptographic API functions:

◆ rc2_decrypt_cbc_to_string()

string Qore::rc2_decrypt_cbc_to_string ( binary  data,
data  key,
data  iv = Qore::DefaultIV,
*string  encoding 
)

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.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keya variable-width decryption key
ivthe initialization vector must be at least 8 bytes long if present
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed
Returns
a string of the decrypted data
Example:
string str = rc2_decrypt_cbc_to_string(data, key);
string rc2_decrypt_cbc_to_string(binary data, data key, data iv=Qore::DefaultIV, *string encoding)
Decrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-l...
Exceptions
RC2-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_string(CRYPTO_ALG_RC2, data, key, iv, ...)
See also
the following generic cryptographic API functions:
Since
Qore 0.8.4 added the encoding parameter to specify the output encoding of the string

◆ rc2_encrypt_cbc()

binary Qore::rc2_encrypt_cbc ( data  data,
data  key,
data  iv = Qore::DefaultIV 
)

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.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be encrypted
keya variable-width encryption key
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the encrypted data
Example:
binary bin = rc2_encrypt_cbc(data, key);
binary rc2_encrypt_cbc(data data, data key, data iv=Qore::DefaultIV)
Encrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-l...
Exceptions
RC2-ENCRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
ENCRYPT-ERRORprocessing error encrypting the data (should not normally happen)
Note
Equivalent to encrypt(CRYPTO_ALG_RC2, data, key, iv)
See also
the following generic cryptographic API functions:

◆ rc4_decrypt()

binary Qore::rc4_decrypt ( binary  data,
data  key,
data  iv = Qore::DefaultIV 
)

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.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keya variable-width decryption key
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the decrypted data
Example:
binary bin = rc4_decrypt(data, key);
binary rc4_decrypt(binary data, data key, data iv=Qore::DefaultIV)
Decrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) a...
Exceptions
RC4-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
See also
the following generic cryptographic API functions:

◆ rc4_decrypt_to_string()

string Qore::rc4_decrypt_to_string ( binary  data,
data  key,
data  iv = Qore::DefaultIV,
*string  encoding 
)

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.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keya variable-width decryption key
ivthe initialization vector must be at least 8 bytes long if present
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed
Returns
a string of the decrypted data
Example:
string str = rc4_decrypt_to_string(encrypted_data, key, NOTHING, "iso-8859-1");
string rc4_decrypt_to_string(binary data, data key, data iv=Qore::DefaultIV, *string encoding)
Decrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) a...
Exceptions
RC4-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
See also
the following generic cryptographic API functions:
Since
Qore 0.8.4 added the encoding parameter to specify the output encoding of the string

◆ rc4_encrypt()

binary Qore::rc4_encrypt ( data  data,
data  key,
data  iv = Qore::DefaultIV 
)

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.

Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be encrypted
keya variable-width encryption key
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the encrypted data
Example:
binary bin = rc4_encrypt(data, key);
binary rc4_encrypt(data data, data key, data iv=Qore::DefaultIV)
Encrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) a...
Exceptions
RC4-ENCRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
ENCRYPT-ERRORprocessing error encrypting the data (should not normally happen)
Note
  • Equivalent to encrypt(CRYPTO_ALG_RC4, data, key, iv)
  • This algorithm does not support (ignores) initialization vectors
See also
the following generic cryptographic API functions:

◆ rc5_decrypt_cbc()

binary Qore::rc5_decrypt_cbc ( binary  data,
data  key,
data  iv = Qore::DefaultIV 
)

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.

Platform Availability:
Qore::Option::HAVE_RC5
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keya variable-width decryption key
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the decrypted data
Example:
binary bin = rc2_decrypt_cbc(data, key);
Exceptions
RC5-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_binary(CRYPTO_ALG_RC5, data, key, iv)
See also
the following generic cryptographic API functions:

◆ rc5_decrypt_cbc_to_string()

string Qore::rc5_decrypt_cbc_to_string ( binary  data,
data  key,
data  iv = Qore::DefaultIV,
*string  encoding 
)

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.

Platform Availability:
Qore::Option::HAVE_RC5
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be decrypted
keya variable-width decryption key
ivthe initialization vector must be at least 8 bytes long if present
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed
Returns
a string of the decrypted data
Example:
string str = rc2_decrypt_cbc_to_string(data, key, NOTHING, "iso-8859-1");
Exceptions
RC5-DECRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
DECRYPT-ERRORprocessing error decrypting the data (for example invalid data)
Note
Equivalent to decrypt_to_string(CRYPTO_ALG_RC5, data, key, iv, ...)
See also
the following generic cryptographic API functions:
Since
Qore 0.8.4 added the encoding parameter to specify the output encoding of the string

◆ rc5_encrypt_cbc()

binary Qore::rc5_encrypt_cbc ( data  data,
data  key,
data  iv = Qore::DefaultIV 
)

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.

Platform Availability:
Qore::Option::HAVE_RC5
Code Flags:
RET_VALUE_ONLY
Parameters
datathe data to be encrypted
keya variable-width encryption key
ivthe initialization vector must be at least 8 bytes long if present
Returns
a binary value of the encrypted data
Example:
binary bin = rc2_encrypt_cbc(data, key);
Exceptions
RC5-ENCRYPT-PARAM-ERRORinvalid initialization vector (less than 8 bytes)
ENCRYPT-ERRORprocessing error encrypting the data (should not normally happen)
Note
Equivalent to encrypt(CRYPTO_ALG_RC5, data, key, iv)
See also
the following generic cryptographic API functions: