necesito todos los metodos hash
Publicado por jose luis (1 intervención) el 17/05/2005 01:43:17
si alguien tiene los metodos hashing programados en c++, le agradeceria mucho que por favor me los mande los necesito es urgente.
Valora esta pregunta


0
#include <iostream>
#include <openssl/md5.h>
#include <cstring>
std::string md5(const std::string& input) {
unsigned char result[MD5_DIGEST_LENGTH];
MD5((const unsigned char*)input.c_str(), input.length(), result);
std::stringstream ss;
for (int i = 0; i < MD5_DIGEST_LENGTH; i++)
ss << std::hex << std::setw(2) << std::setfill('0') << (int)result[i];
return ss.str();
}
#include <iostream>
#include <openssl/sha.h>
#include <cstring>
std::string sha256(const std::string& input) {
unsigned char result[SHA256_DIGEST_LENGTH];
SHA256((const unsigned char*)input.c_str(), input.length(), result);
std::stringstream ss;
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
ss << std::hex << std::setw(2) << std::setfill('0') << (int)result[i];
return ss.str();
}