views:

48

answers:

1

I often code in PHP and for caching I like to use the md5 of a particular request (ie an sql statement) as the name of my cache key. md5 gives me a pretty string that is unique and thus, the reason why I use it.

Now, I am trying to implement some caching at the browser level using JQuery. It is for an address verifier form. To reduce the number of ajax calls I was thinking of turning the given address into a unique string that I could use as a key in an array.

Now I know there are plenty of JS MD5 solutions out there, but I was curious to know if JS or even JQuery have something native that I could use. Something like md5 or base64Encode.

+1  A: 

A faster alternative Im not sure (typically any speed increase will be in ms unless you are processing the encoded keys through a defined function). As far as the default encoding toolset is concerned, as far as Im aware, other than the standard encoding sets such as those you mention, thats about it.

What some people choose to do is to create their own encoding sets (easier if you dont require them to be decoded at a later date). If I dont need encryption per se but a UID, what I tend to opt for is a slight adaptation of basic BASE 64 encoding- say, appending a string with a random 'x' length number, then b64 encoding that...

jQuery does have one or two plugins you may want to look at, i.e.

http://plugins.jquery.com/project/base64

Hope this may help- good luck!

Ergo Summary