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

  • SEARCH
  • Home
  • 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 9121263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:49:16+00:00 2026-06-17T05:49:16+00:00

I’ve encountered a nice base64 encoding implementations in JS, its typical job is to

  • 0

I’ve encountered a nice base64 encoding implementations in JS, its typical job is to take a utf8-encoded text input and give a base64 output (and vice versa). But I’m surprised I’ve never seen a suitable solution for base32! Well, that’s all I’ve found:
1. agnoster/base32-js. This is for nodejs, and its main base32.encode function takes input as a string.
2. base32-encoding-in-javascript. This takes input as a string, too. Moreover, this lacks for decoder.
But I need the script to take the input as HEX (or even base64)!!! If my input is Hex, then output will be shortened; if my input is base64, then, according to wikipedia, output will be 20% oversized – that’s what I expect.
Given the alphabet “ABCDEFGHIJKLMNOPQRSTUVWXYZ234567”:

hexdata: 12AB3412AB3412AB3412AB34;

//RFC 3548 chapter 5: The encoding process represents 40-bit groups of input bits 
//as output strings of 8 encoded characters. 

 bin     b32
00010 --> C
01010 --> K
10101 --> V
10011 --> T
01000 --> I
00100 --> E
10101 --> V
01011 --> L
//+40 bits
00110 --> G
10000 --> Q
01001 --> J
01010 --> K
10110 --> W
01101 --> N
00000 --> A
10010 --> S
//+16 bits
10101 --> V  //RFC 3548 chapter 5 case 3:
01100 --> M  //the final quantum of encoding input is exactly 16 bits; 
11010 --> 2  //here, the final unit of encoded output will be four characters 
0     -->    //followed by four "=" padding characters
//zero bits are added (on the right) to form an integral number of 5-bit groups
--> 
00000 --> A
--> base32data: CKVTIEVLGQJKWNASVM2A====  

I’d like to see javascript hextobase32("12AB3412AB3412AB3412AB34") yielding CKVTIEVLGQJKWNASVM2A==== and base32tohex("CKVTIEVLGQJKWNASVM2A====") returning 12AB3412AB3412AB3412AB34.

UPDATE
In addition to agnoster/base32-js, which doesn’t seem to handle padding problems, I met the following libs:
1. Nibbler. According to wikipedia, there are two ways to encode: 8-bit and 7-bit. This lib even has an option dataBits (maybe it’s meant only for base64, not for base32, I don’t know) to choose 8-bit or 7-bit way! But this project is not evolving at all. And one more thing: reading comments, I see that this lib also has padding issues!
2. Chris Umbel thirty-two.js. This lib decided to carry the whole byte table with it for decoding. And you can see this interesting comment in the source code:
/* byte by byte isn’t as pretty as quintet by quintet but tests a bit
faster. will have to revisit. */
But not evolving.
3. jsliquid.Data. Operates on so-called binary large objects. Seems to get the job done, but since its code is heavily obfuscated, I can’t even see how to define my custom alphabet.
And now, I think that a fully functional Javascript UTF8/hex/base32/base64 library of a reliable quality would be great, but currently, situation is dubious.

  • 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-17T05:49:17+00:00Added an answer on June 17, 2026 at 5:49 am

    Well the first node.js takes input in binary string, what you want is for it take input in base-16 or base-64. Since you already
    have nice base-64 implementations and base16 decoder is dead simple to do, I think you’re set.

    https://github.com/agnoster/base32-js/blob/master/lib/base32.js Also works for browsers out of the box.

    So you’d use it like this in browser:

    var result = base32.encode(base64decode(base64input));
    var result2 = base32.encode(base16decode(base16input));
    var result3 = base32.encode(binaryInput);
    

    Where base16decode:

    function base16decode( str ) {
        return str.replace( /([A-fa-f0-9]{2})/g, function( m, g1 ) {
            return String.fromCharCode( parseInt( g1, 16 ));
        });
    }
    

    http://jsfiddle.net/YPuF3/1/

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to select an H1 element which is the second-child in its group
I have been unable to fix a problem with Java Unicode and encoding. The
I have a reasonable size flat file database of text documents mostly saved in
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.