OK hopefully the title didn't scare you away. I'm creating a sha1 hash using Ruby but it has to follow a formula that our other system uses to create the hash.
How can I do the following via Ruby? I'm creating hashes fine - but the format stuff is confusing me - curious if there's something equiv in the Ruby standard library.
System Security Cryptography (MSDN)
Here's the C# code that I'm trying to convert to Ruby. I'm making my hash fine, but not sure about the 'String.Format("{0,2:X2}' part.
//create our SHA1 provider SHA1 sha = new SHA1CryptoServiceProvider(); String str = "Some value to hash"; String hashedValue; -- hashed value of the string //hash the data -- use ascii encoding byte[] hashedDataBytes = sha.ComputeHash(Encoding.ASCII.GetBytes(str)); //loop through each byte in the byte array foreach (byte b in hashedDataBytes) { //convert each byte -- append to result hashedValue += String.Format("{0,2:X2}", b); }