This is the C # code:
byte[] pb = System.Text.Encoding.UTF8.GetBytes(policy.ToString()); // Encode those UTF-8 bytes using Base64 string policyB = Convert.ToBase64String(pb); // Sign the policy with your Secret Key using HMAC SHA-1. System.Security.Cryptography.HMACSHA1 hmac = new System.Security.Cryptography.HMACSHA1(); hmac.Key = System.Text.Encoding.UTF8.GetBytes(secretKey); byte[] signb = hmac.ComputeHash(System.Text.Encoding.UTF8.GetBytes(policyB)); string signature = Convert.ToBase64String(signb);
How to do the same in Ruby on rails? In particular, I need to know the functions in order to get the bytes from the string and base64, encode them and calculate the hash hash.
source share