Reputation: 1607
I am trying to build an ASP.NET MVC application, which will use Thumbor as a photo resizing backend, but have been running into problems with the security. Thumbor uses a SHA1 HMAC hash as a security system, which is based on the URL. So, the URL may look like:
http://thumbor-server/1234567890123456789012345678/300x200/smart/path/to/image.jpg
1234567890123456789012345678 being the hmac made up of a secret key and the 300...image.jpg section...
anyway, i can create the HMAC value alright, or at least i think i can, but when generating the URL, Thumbor sugests using the urlsafe_base64encode function from Python. I have tried System.Convert.ToBase64String, but thats not working, and url encoding the string does not work either. By "not working", i mean Thumbor is telling me the URL is malformed. There is not much to go by...
So, is there an equivalent? and if not, how would one go about generating a string the way it does?
Upvotes: 3
Views: 1366
Reputation: 1607
I have managed to get this working, by taking the Base64 string and replacing the +
char with -
and the /
char with a _
. This seems to be the way that Python is doing its urlsafe_b64encode
Upvotes: 3