Backspace is not handled properly in this version of Qonsole
. Add an event handler that does the proper thing in response to backspace.
Modify the Qonsole
to support multiple simultaneous terminals in separate tabs.
According to NIST, the U.S. National Institute of Standards and Technology:
A hash function takes binary data, called the message, and produces a condensed representation, called the message digest. A cryptographic hash function is a hash function that is designed to achieve certain security properties. The Federal Information Processing Standard 180-2, Secure Hash Standard, specifies algorithms for computing five cryptographic hash functions: SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512.
For any given chunk of data, a good cryptographic hash function must reliably produce a digest that is essentially unique; that is, no other chunk of data would yield the same digest using that function. Hashing is a one-way operation; that is, it is generally not possible to reverse the process and produce the data chunk from the digest.
Secure passwords can be handled by storing only the digest for each password. When a user logs in and enters a password, that string is immediately hashed, and the resulting digest is compared with the stored digest. If they match, the user has been validated. Otherwise, the login is not successful. The user's password is never stored and exists in memory only long enough to compute its digest.
Qt has a class named QCryptographicHash that provides a hash function for computing the cryptographic hash of a given QByteArray. As of QT 4.7, the algorithms, SHA-1, MD4, and MD5 are supported.[103]
Write a simple application that takes two command-line arguments: a string to be hashed and an argument that specifies the algorithm to be used. The application should send the resulting digest to standard output. For example:
crhash "my big secret" md5
would result in the output of a digest consisting of "binary" data.
Example 17.14. solution/pwmgr/HashApp/hash.cpp
#include <QTextStream> #include <QCryptographicHash> #include <QByteArray> #include <QStringList> #include <QCoreApplication> QTextStream cout(stdout); QTextStream cerr(stderr); QString usage() { return QString("usage:\n\t%1\n\t%2\n\t%3\n\t%4") .arg("encrypt string alg") .arg("where alg can be one of three algorithms:") .arg("Md4, Md5, or Sha1. If this switch is absent") .arg("the default will be Sha1."); } int main(int argc, char** argv) { QCoreApplication qca(argc, argv); QStringList al(qca.arguments()); if(al.count() < 2) { cerr << usage() << endl; return 1; } al.takeFirst(); //Get rid of the app name. QByteArray qba; qba.append(al.takeFirst()); // String to be hashed QString algarg = al.takeFirst().toLower(); QCryptographicHash::Algorithm alg; if(algarg == "md4") alg = QCryptographicHash::Md4; else if(algarg == "md5") alg = QCryptographicHash::Md5; else alg = QCryptographicHash::Sha1; cout << QCryptographicHash::hash(qba, alg) << endl; }
<include src="solution/pwmgr/HashApp/hash.cpp" href="solution/pwmgr/HashApp/hash.cpp" role="solution" mode="cpp"/>
Using the crhash
application from part (a) as a separate process, write an application that manages club member data, including userid, password, email address, street address, city, state, ZIP, and phone number. Passwords should be stored only as digests. Make sure that you serialize the club member data properly.
[ fromfile: qprocess.xml id: x-qprocess ]
[103] MD4 and MD5 are Message-Digest algorithms designed by Ron Rivest prior to the development of SHA-1, which has since been superceded by the SHA-2 family of hash functions. See http://en.wikipedia.org/wiki/MD5 for more details.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |