Hello, I am trying to get images from wikipedia API. API only gives name of the files. According to here wikipedia encodes filename with md5 and puts it under:
http://upload.wikimedia.org/wikipedia/commons/FIRST_CHAR_MD5/FIRST_TWO_CHAR_MD5/FILE_NAME
But when i try to encode filenames with c#'s md5 algorithm i get different md5 hash code. How can i get same hashcode?
System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
md5.Initialize();
byte[] buffer = System.Text.Encoding.ASCII.GetBytes(filename);
byte[] bufferEncrypt = md5.ComputeHash(buffer, 0, buffer.Length);
string pwdX = System.Convert.ToBase64String(bufferEncrypt);
md5.Clear();
byte[] bytes = System.Convert.FromBase64String(pwdX);
StringBuilder sb = new StringBuilder();
foreach (byte b in bytes)
sb.Append(b.ToString("x2"));
print (sb.ToString());
EDIT: Seems like the problem is with the specific characters like “% ü …”.