// Hex JavaScript decoder
// Copyright (c) 2008 Lapo Luchini <lapo@lapo.it>

// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
// 
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Hex = {};

Hex.decode = function(a) {
    if (Hex.decoder == undefined) {
        var hex = "0123456789ABCDEF";
        var allow = " \f\n\r\t\u00A0\u2028\u2029";
        var dec = [];
        for (var i = 0; i < 16; ++i)
            dec[hex.charAt(i)] = i;
        hex = hex.toLowerCase();
        for (var i = 10; i < 16; ++i)
            dec[hex.charAt(i)] = i;
        for (var i = 0; i < allow.length; ++i)
            dec[allow.charAt(i)] = -1;
        Hex.decoder = dec;
    }
    var out = [];
    var bits = 0, char_count = 0;
    for (var i = 0; i < a.length; ++i) {
        var c = a.charAt(i);
        if (c == '=')
            break;
        c = Hex.decoder[c];
        if (c == -1)
            continue;
        if (c == undefined)
            throw 'Illegal character at offset ' + i;
        bits |= c;
        if (++char_count >= 2) {
            out[out.length] = bits;
            bits = 0;
            char_count = 0;
        } else {
            bits <<= 4;
        }
    }
    if (char_count)
        throw "Hex encoding incomplete: 4 bits missing";
    return out;
}
