
CryptoTools 3.0
API
Table of contents. 2
Objects, methods and attributes. 3
Attributes. 3
Key. 3
Result 3
IV.. 3
Methods. 3
Encrypt 3
Decrypt 3
EncryptText 3
DecryptText 3
EncryptFile. 3
DecryptFile. 3
DeriveKeyFromPassword. 3
This section describes the methods and attributes of all the
encryption and encoding objects available in the CryptoTools package. A list of
all objects will that implement it will be provided.
The Key attribute is implemented by the following objects:
- CryptoDES (Data Encryption Standard)
- CryptoTripleDES
(Three keys DES)
The Result attribute is implemented by all encryption
components:
- CryptoDES (Data Encryption Standard)
- CryptoTripleDES (Three keys DES)
- CryptoBase64 (Text encoding)
- CryptoMD5
(MD5 Hashing algorithm)
The IV attribute is implemented by the following two
algorithms:
- CryptoDES (Data Encryption Standard)
- CryptoTripleDES
(Three keys DES)
The Encrypt method is available in all four encryption
components:
- CryptoDES (Data Encryption Standard)
- CryptoTripleDES (Three keys DES)
- CryptoBase64 (Text encoding)
- CryptoMD5
(MD5 Hashing algorithm)
The Encrypt method encrypts a binary block of data and
stores the result in the Result attribute.
The Decrypt method is available in the following encryption
components:
- CryptoDES (Data Encryption Standard)
- CryptoTripleDES (Three keys DES)
- CryptoBase64
(Text encoding)
The Decrypt method decrypts a binary block of data that was
produced by a call to the Encrypt method. To decrypt the data, the Key
attribute must be set to the same key that was used to encrypt the data.
Decrypt is not available for MD5 because the result produced
by a hashing function is impossible to decrypt.
The EncryptText method is available in all four encryption
components:
- CryptoDES (Data Encryption Standard)
- CryptoTripleDES (Three keys DES)
- CryptoBase64 (Text encoding)
- CryptoMD5
(MD5 Hashing algorithm)
This method is a specialization of the Encrypt method.
Instead of encrypting a block of binary data, the EncryptText function encrypts
text. This function does not support UNICODE standard.
The EncryptText is not available for C and C++, as text is
an array of bytes.
The DecryptText method is available in the following
encryption components:
- CryptoDES (Data Encryption Standard)
- CryptoTripleDES (Three keys DES)
- CryptoBase64
(Text encoding)
The Decrypt text method returns the original text string.
The result can also be accessed as binary data trough the Result attribute.
Decrypt is not available for MD5 because the result produced
by a hashing function is impossible to decrypt.
The EncryptFile method is available in all four encryption
components:
- CryptoDES (Data Encryption Standard)
- CryptoTripleDES (Three keys DES)
- CryptoBase64 (Text encoding)
- CryptoMD5
(MD5 Hashing algorithm)
Encrypt file is a helper function wrapping the
functionalities of the Encrypt method plus all the code necessary to open the
source file and create and save the result into the target file.
The EncryptFile method of the CryptoMD5 object returns the
hash as a text string. The resulting hash can also be accessed trough the
Result attribute.
The DecryptFile method is available in the following
encryption components:
- CryptoDES (Data Encryption Standard)
- CryptoTripleDES (Three keys DES)
- CryptoBase64
(Text encoding)
DecryptFile will read the content of an encrypted file,
decrypt it and save the result to the target file.
This function is not available for CryptoMD5 because hashing
results are impossible to decrypt.
The DeriveKeyFromPassword method is implemented by the
following two algorithms:
- CryptoDES (Data Encryption Standard)
- CryptoTripleDES
(Three keys DES)
This function generates an encryption key from the password
it receives in parameter. This is a very helpful function for languages where
it is complicated to work with byte arrays.
The following steps generate the encryption key:
- The password is converted to a bytes array using ASCII
characters mapping.
- The salt bytes array, if not null, is concatenated to the
password byte array.
- The
resulting bytes array is then hashed N times using MD5 hashing algorithm.
The resulting 128 bits hash is split in two parts, K1 and
K2. For the DES encryption object, the key is set to the first part K1. For
TripleDES, both parts are concatenated in the following manner: K1+K2+K1, to
form the encryption key. This type of key, for TripleDES, is sometime called
2DES.