Whirlpool hashing with OpenSSL in C++

In Technology/Code
Scroll this
#include <iostream>
#include <cstring>
#include <openssl/whrlpool.h>

using namespace std;

int main(int argc, char** argv) {

 cout << "you have entered:" << argv[1] << endl;

 char hash = argv[1][0];

 unsigned char digest[WHIRLPOOL_DIGEST_LENGTH];
 char tohash[] = {hash};

 WHIRLPOOL((unsigned char*)&tohash,strlen(tohash),(unsigned char*)&digest);

 char mdString[300];

 for(int i = 0; i < 64; i++)
 sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]);

 printf("whirlpool digest: %s\n", mdString);

 return 0;
[email protected]:~/CLionProjects/playground$ g++ main.cpp -o whash -lcrypto
[email protected]:~/CLionProjects/playground$ ./whash "Hello World"
you have entered:Hello World
whirlpool digest: c0cb42019e235d0c82318d44aab396357457c1d4aaa8b2721d39893b78b80b7db2e2ef6cf1f3d3fdc7f4ffd471f8d46c8a057b68188796b6f4d1574be7af8df0


I like to solve core problems with simple innovations!

More Posts - Website

Submit a comment