please, I tried in everyway to make a good MD5 criptography or SHA1… I managed to do that (I’m using C#) in some ways… it works in Unity.
But when I compare with ActionScript, or PHP, or in MySQL… it returns me another data.
PHP, ActionScript and MySQL returns me the same MD5 code (or SHA1, same too). But in C#, I tried 5 diferents codes for MD5 or SHA1 and it keeps returning me a wrong code (not really wrong, just diferent from the PHP, ActionScript or MySQL)…
Anyone can help me? I even do not put the “salt” on it because just MD5 is not working…
Someone can give me a simple MD5 that returns me the same code as MySQL?
That won’t have any effect on anything with regards to encryption. You do realize that every time that something gets encrypted like the small letter “a” or the big letter “A” it will never have the same encrypted formula applied to it right? It is based on the public/private key pairing.
MD5 and SHA1 are one-way cryptographic hash functions. You use them to hash data - there’s no way to de-hash it.
MD5 functions in C#, PHP, MySQL etc will all return the same hash for the same input. If you get different hashes, then there has to be some difference in the inputs you pass to the functions.
Giving some examples that show how exactly you use the md5 functions in those languages will make helping you easier if you’re problem is not already answered.
public static string CalculateMD5Hash(string input) {
// Primeiro passo, calcular o MD5 hash a partir da string
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
byte[] hash = md5.ComputeHash(inputBytes);
// Segundo passo, converter o array de bytes em uma string haxadecimal
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++) {
sb.Append(hash[i].ToString("X2"));
}
return sb.ToString().ToLower();
}
public static string Md5Sum(string strToEncrypt) {
System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding();
byte[] bytes = ue.GetBytes(strToEncrypt);
// encrypt bytes
System.Security.Cryptography.SHA1CryptoServiceProvider md5 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
byte[] hashBytes = md5.ComputeHash(bytes);
// Convert the encrypted bytes back to a string (base 16)
string hashString = "";
for (int i = 0; i < hashBytes.Length; i++) {
hashString += System.Convert.ToString(hashBytes[i], 16).PadLeft(2, '0');
}
return hashString.PadLeft(32, '0');
}
I cant run it now, but I can sure you it returns me a diferent data that the built-in functions of PHP and ActionScript returns me (even MySQL).
I have tried another ones, but I deleted and dont remember
EDIT: I did not decript this, I only compare the results of other languages (PHP, AS and MySQL)… sorry the wrong words
Use
Base64String
insted of ASCII
and caps/no caps has nothing to do with either hash or encryption
and I never said that hashing was encryption at all only that case has nothing to do with encryption going
I have already given him RSA code project in C# which is encryption not hashing
@zumwalt
I remember your code too… I’m trying another things, then I will try that code. THanks
@andeeee
I tried exacly that code (it was the first) and its false, the generated code its diferent than PHP, AS and MySQL generated.
The MD5 in Unifywiki is not wrong, it works… but it gives a diferent code…
EDIT: I will try diferent inputs, maybe I’m doing something wrong (but I tried several ways)