Parsing Strings in C++ Using a Hash
Hashes are an important security requirement for applications today. A hash creates a unique numeric equivalent of any string you feed it. Theoretically, you can’t duplicate the number that the hash creates by using another string. A hash isn’t reversible — it isn’t the same as encryption and decryption.
A common use for hashes is to send passwords from a client to a server. The client converts the user’s password into a numeric hash and sends that number to the server. The server verifies the number, not the password. Even if people are listening in, they have no way to ascertain the password from the number; therefore they can’t steal the password for use with the target application.
The latest version of Code::Blocks provides excellent support for hashes. However, in order to use it, you must enable support for C++ 11 extensions. After you enable the required support, you can create the HashingStrings example shown here to demonstrate the use of hashes.
using namespace std;
hash<const char*> MyHash;
cout << "The hash of "Hello World" is:" << endl;