C++ All-in-One For Dummies
Book image
Explore Book Buy On Amazon

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.

#include 
#include 
using namespace std;
int main()
{
    hash MyHash;
    cout << "The hash of "Hello World" is:" << endl;

About This Article

This article is from the book:

About the book author:

John Mueller has produced 114 books and more than 600 articles on topics ranging from functional programming techniques to working with Amazon Web Services (AWS). Luca Massaron, a Google Developer Expert (GDE),??interprets big data and transforms it into smart data through simple and effective data mining and machine learning techniques.

This article can be found in the category: