Hello GeoCoding.Net team,
Thanks for the code!
I've been using a basic URL signing class for Google's premier API. Do
you guys already have this or would you like to use this code? Can't
remember where I got this from to be honest, otherwise I'd credit the
original author. (No license in the code.)
public struct GoogleSignedUrl
{
public static string Sign(string url, string keyString)
{
ASCIIEncoding encoding = new ASCIIEncoding();
// converting key to bytes will throw an exception, need
to replace '-' and '_' characters first.
string usablePrivateKey = keyString.Replace("-",
"+").Replace("_", "/");
byte[] privateKeyBytes =
Convert.FromBase64String(usablePrivateKey);
Uri uri = new Uri(url);
byte[] encodedPathAndQueryBytes =
encoding.GetBytes(uri.LocalPath + uri.Query);
// compute the hash
HMACSHA1 algorithm = new HMACSHA1(privateKeyBytes);
byte[] hash =
algorithm.ComputeHash(encodedPathAndQueryBytes);
// convert the bytes to string and make url-safe by
replacing '+' and '/' characters
string signature =
Convert.ToBase64String(hash).Replace("+", "-").Replace("/", "_");
// Add the signature to the existing URI.
return url + "&signature=" + signature;
}
}
--
You received this message because you are subscribed to the Google Groups "GeoCoding.Net" group.
To post to this group, send email to
geocod...@googlegroups.com.
To unsubscribe from this group, send email to
geocodingnet...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/geocodingnet?hl=en.