in reply to Decoding Base32

I am attempting to use this to batch convert base32 SHA-1 hashes without much luck. The posted urnDecode gives the standard "Data contains non-base32 characters." Any ideas on what would need to be done to fix it? According to the module, decode_base32 performs a lc(). I've tried tossing in a lc() and an unpack(H32,) without any luck.

Replies are listed 'Best First'.
Re^2: Decoding Base32
by Anonymous Monk on Apr 19, 2010 at 14:53 UTC
    I should clarify, my lc() and unpack were placed inside decode_base32() in different variations to get the data to line up.

      Maybe you want to show some code, and some sample data in addition to the error message? From a first guess, I would say that your data contains non-base32 characters.

        That would be an intelligent first guess ...

        The code used is the code posted above. The only modifications I've done are attempting to add (and remove) lc and unpack functions within the decode_base32 to condition the data properly. I am not completely confident in my understanding of unpack, but one such attempt looked like:

        print "SHA1: " . udecode_base32(unpack('H32', $urn_decode)) . "\n";

        As for example data, I simply grabbed a SHA-1 of a zip file using md5deep. That was converted to base32 using both this script and BitCollider 1 provided by bitzi.com.

        SHA-1: 58d18761f662f8cb4cf26de2f82f1b5c6e9a9857
        SHA-1 Base32: LDIYOYPWML4MWTHSNXRPQLY3LRXJVGCX

        1 http://bitzi.com/bitcollider