12. Beyond HTML
Introduction to QCryptography
<< * Introduction to QRssFeed   |   Back to Main   |   Introduction to QI18n (Internationalization) >>

View Source
will open in a new window
Implementing Cryptography
The QCryptography class is used to implement cryptography for your site and back-end. It primarly serves as a cohesive wrapper around the libmcrypt library, which must also be installed. (According to the PHP documentation, you must have libmcrypt v2.5.6 or greater for PHP 5)

By default, QCryptography will use the TripleDES cipher in Electronic Codebook mode. It will also conveniently do base64 conversion (similar to MIME-based Base64 encoding) so that the resulting encrypted data can be used in text-based streams, GET/POST data, URLs, etc.

However, note that any of these options can be changed at any time. Through the libmcrypt library, QCryptography supports most of the industry accepted ciphers, including DES, ARC4, Blowfish, Rijndael, RC2, RC4, RC6, etc.

You can statically specify a "default" cipher, mode, base64 flag and key by modifying the appropriate static member variable on the class, or you can specify these fields explicitly when constructing a new instance of QCryptography.

QCryptography also supports the encryption and decryption of entire files.

For more information about the libmcrypt library, please refer to the PHP Documentation.

TripleDES, Electronic Codebook Encryption

Original Data: The quick brown fox jumps over the lazy dog.
Encrypted Data: Y;` )J7R.73( Ʌ6r 7>
Decrypted Data: The quick brown fox jumps over the lazy dog.


TripleDES, Electronic Codebook Encryption (with Base64 encoding)

Original Data: Just keep examining every low bid quoted for zinc etchings.
Encrypted Data: kWyaX6t4HTawRh0zGEqddyHu6pNIYs4LeRu6sCSGHDEsuHQfx4V1AgyLVtiKBnW68ccD_2z3m1tsI3-zdeVSgg
Decrypted Data: Just keep examining every low bid quoted for zinc etchings.