Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8537881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:00:29+00:00 2026-06-11T11:00:29+00:00

<script> // This would be the place to edit if you want a different

  • 0
    <script>
// This would be the place to edit if you want a different
// Base32 implementation

var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345'


/**
 * Build a lookup table and memoize it
 *
 * Return an object that maps a character to its
 * byte value.
 */

var lookup = function() {
    var table = {}
    // Invert 'alphabet'
    for (var i = 0; i < alphabet.length; i++) {
        table[alphabet[i]] = i
    }

    lookup = function() { return table }
    return table
}


// Functions analogously to Encoder

function Decoder() {
    var skip = 0 // how many bits we have from the previous character
    var byte = 0 // current byte we're producing

    this.output = ''

    // Consume a character from the stream, store
    // the output in this.output. As before, better
    // to use update().
    this.readChar = function(char) {
        if (typeof char != 'string'){
            if (typeof char == 'number') {
                char = String.fromCharCode(char)
            }
        }
        //char = char.toLowerCase()
        var val = lookup()[char]
        if (typeof val == 'undefined') {
            // character does not exist in our lookup table
            return // skip silently. An alternative would be:
            // throw Error('Could not find character "' + char + '" in lookup table.')
        }
        val <<= 3 // move to the high bits
        byte |= val >>> skip
        skip += 5
        if (skip >= 8) {
            // we have enough to preduce output
            this.output += String.fromCharCode(byte)
            skip -= 8
            if (skip > 0) byte = (val << (5 - skip)) & 255
            else byte = 0
        }

    }

    this.finish = function(check) {
        var output = this.output + (skip < 0 ? alphabet[bits >> 3] : '') + (check ? '$' : '')
        this.output = ''
        return output
    }
}

Decoder.prototype.update = function(input, flush) {
    for (var i = 0; i < input.length; i++) {
        this.readChar(input[i])
    }
    var output = this.output
    this.output = ''
    if (flush) {
      output += this.finish()
    }
    return output
}

/** Convenience functions
 *
 * These are the ones to use if you just have a string and
 * want to convert it without dealing with streams and whatnot.
 */


// Base32-encoded string goes in, decoded data comes out.
function decode(input) {
    var decoder = new Decoder()
    var output = decoder.update(input.split("").reverse().join("")+'A', true)
    return output

}

function toHex(str) {
    var hex = '';
    for(var i=0;i<str.length;i++) {
       //hex += ''+("00" + str.charCodeAt(i).toString(16)).substr(-2);
       hex += str.charCodeAt(i).toString(16);
       }
    return hex;
}

convertHex = toHex(decode('A0C4KB'));
alert(convertHex);
</script>

The above script works fine on FF and Chrome and gives me the correct hex value.
The alert output comes as expected with

abc2d0

For IE, this doesn’t seem to work. I get all

ffffffff

This is a Base32 implementation that I pickep up from https://github.com/agnoster/base32-js

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:00:30+00:00Added an answer on June 11, 2026 at 11:00 am

    Internet Explorer’s JScript engine doesn’t support array access to string constants. You’ll have to replace alphabet[i] with alphabet.charAt(i) to get it working. I thought MS had addressed this issue, though, but I could be wrong/too hopeful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This would be an example of database table: PHP script should limit query result
This would be a HTML file: <li class=msgln>hello</li><li class=msgln>hi</li><li class=msgln>hey</li> And php script: $fp
I'm not sure how simple this would be, but I'm using a script which
I would like to run this script (embed drive list in a site) that
I would like to use this script https://github.com/jeromeetienne/jquery-qrcode (or is there even a better
Would anyone now why this script is disabling my nav in webkit browsers $(document).ready(function
I would like to run a script in production. This script generates a record
I have a script. I would like to give this script a quiet mode
I would like to have a script in the head like this: <script type=text/javascript
Hi I have this basic random quote script, but I would like it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.