[C] Hashage MD5
Utilisateur anonyme
-
ghuysmans99 Messages postés 2496 Date d'inscription Statut Contributeur Dernière intervention -
ghuysmans99 Messages postés 2496 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
Je programme en C et je voudrais savoir comment hasher un mot en md5 ?
Merci bcp ^^
Je programme en C et je voudrais savoir comment hasher un mot en md5 ?
Merci bcp ^^
Configuration: Windows ... malheureusement ...
12 réponses
-
Si t'es sous Windows, utilise CryptoAPI.
-
-
J'en ai même deux :
- MSDN, LA référence en programmation Windows : https://docs.microsoft.com/en-us/windows/win32/seccrypto/hashing?redirectedfrom=MSDN
- Un code d'exemple sur CPPFrance : https://codes-sources.commentcamarche.net/ -
-
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question -
Mais il existe pas une fonction spécifique, je veux dire sans utiliser le main, du genre :
char md5 (char acoder[]){ blablabla ... return code; } int main (){ md5(Bonjour); }
?? -
Tu dois la créer toi-même.
-
Il y a un problème ... Je cherche une fonction de Hash md5 pour un char, pas pour un fichier ...
-
-
-
J'ai ça en C++ :
#define WIN32_LEAN_AND_MEAN #define _CRT_SECURE_NO_WARNINGS #include <windows.h> #include <wincrypt.h> #include <stdio.h> char* GenericHash(unsigned int AlgId,char* Buffer, int lBuffer) { HCRYPTPROV hProv; HCRYPTHASH hHash; BYTE* Hash; DWORD lHash, len; if (CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET)) { if (CryptCreateHash(hProv,AlgId,0,0,&hHash)) { if (CryptHashData(hHash,(BYTE*)Buffer,lBuffer,0)) { if (CryptGetHashParam(hHash,HP_HASHSIZE,(BYTE*)&lHash,&len,0)) { Hash = new BYTE[lHash]; if (!Hash) return NULL; if (!CryptGetHashParam(hHash,HP_HASHVAL,Hash,&lHash,0)) { delete[] Hash; return NULL; } } } else return NULL; } else return NULL; } else return NULL; CryptDestroyHash(hHash); CryptReleaseContext(hProv,0); char* sHash = new char[lHash*2+1]; memset(sHash,0,lHash*2+1); for (unsigned char i = 0; i <= lHash-1; i++) { sprintf(sHash+(i*2),"%02X",Hash[i]); } delete[] Hash; return sHash; } -
-
> Mais il existe pas une fonction spécifique,
Si , il y a les apis MD5 sous Windows (cf chez les pros pour les exemple https://www.ovh.co.uk/mail/