I’ve been reading up on the OAuth spec. And for call signing one of the ways is by using HMAC-SHA1 as a hash function.
This is great and all - but since I need to call my own API from Javascript I needed a way to do this algorithm in Javascript. Well, off to Google I went.
After a few misses I found the script made by Paj which is located at http://pajhome.org.uk/crypt/md5/sha1src.html.
This is also where I got the MD5 algorithm when I needed one of those.
The next step was to add a Mootools wrapper for it, so I can do things like "some string".hmac_sha1("key");
For this I conjured up this little piece of code:
/*
* Mootools wrapper for the SHA1 functions.
* This adds String.sha1 and String.hmac_sha1
* Requires http://pajhome.org.uk/crypt/md5/sha1src.html
*/
String.extend({
sha1: function(output) {
if( output == 'base64' ) {
return b64_sha1(this);
} else if( output == 'hex' ) {
return hex_sha1(this);
} else {
return str_sha1(this);
}
},
hmac_sha1: function( key, output ) {
if( output == 'base64' ) {
return b64_hmac_sha1(key, this);
} else if( output == 'hex' ) {
return hex_hmac_sha1(key, this);
} else {
return str_hmac_sha1(key, this);
}
}
});
-fangel
Read more | March 16th, 2008 | JavaScript | No comments
Since most of you probably aren’t going to fetch the SVN version of my iCalendar parser - known as SG_iCalReader - I’ve made a simple alpha-page.
It allows you to type in the URL of a iCalendar feed, and it will display the contents of the feed in a nice week-view calendar.
SG iCalReader Tryout (http://sevengoslings.net/try_ical/)
Note: The [...]
Read more | March 1st, 2008 | PHP, SG_iCalReader | No comments
I’ve got myself a new project. A iCalendar parser.
Right now it’s getting close to some initial testing. Which is why I need you!
Do you have any need for parsing iCalendar files/feeds? If you do, I’d like to bounce some ideas on how to create the API.
Also - I’m looking for testing-material. If you have a [...]
Read more | February 26th, 2008 | PHP, SG_iCalReader | 6 comments
I am pretty much clueless when it comes to what I should blog about. This is what came up in my mind when pondering what to write about:
PHP - But I haven’t really coded anything or much worse: felt like coding anything in the while.
Web Security - But I’m not sure I’m best suited for [...]
Read more | February 3rd, 2008 | Personal | 1 comment
After installing OS X Leopard I quickly realized that the bundled PHP lacks a very important (at least to me) part. PDO MySQL.
UPDATE:
This was a a build that worked - almost. You couldn’t get GD, PEAR or PECL working. So I set out to fix this issue. But what - Sean Coates had already found [...]
Read more | November 19th, 2007 | Personal | 5 comments