dist/base32.js
function Encoder() {
    var skip = 0 // how many bits we will skip from the first byte
    var bits = 0 // 5 high bits, carry from one byte to the next

    this.output = ''

    // Read one byte of input
    // Should not really be used except by "update"
    this.readByte = function(byte) {
        // coerce the byte to an int
        if (typeof byte == 'string') byte = byte.charCodeAt(0)

        if (skip < 0) { // we have a carry from the previous byte
            bits |= (byte >> (-skip))
        } else { // no carry
            bits = (byte << skip) & 248
        }

        if (skip > 3) {
            // not enough data to produce a character, get us another one
            skip -= 8
            return 1
        }

        if (skip < 4) {
            // produce a character
            this.output += alphabet[bits >> 3]
            skip += 5
        }

        return 0
    }

    // Flush any remaining bits left in the stream
    this.finish = function(check) {
        var output = this.output + (skip < 0 ? alphabet[bits >> 3] : '') + (check ? '$' : '')
        this.output = ''
        return output
    }
}
function Encoder() {
    var skip = 0 // how many bits we will skip from the first byte
    var bits = 0 // 5 high bits, carry from one byte to the next

    this.output = ''

    // Read one byte of input
    // Should not really be used except by "update"
    this.readByte = function(byte) {
        // coerce the byte to an int
        if (typeof byte == 'string') byte = byte.charCodeAt(0)

        if (skip < 0) { // we have a carry from the previous byte
            bits |= (byte >> (-skip))
        } else { // no carry
            bits = (byte << skip) & 248
        }

        if (skip > 3) {
            // not enough data to produce a character, get us another one
            skip -= 8
            return 1
        }

        if (skip < 4) {
            // produce a character
            this.output += alphabet[bits >> 3]
            skip += 5
        }

        return 0
    }

    // Flush any remaining bits left in the stream
    this.finish = function(check) {
        var output = this.output + (skip < 0 ? alphabet[bits >> 3] : '') + (check ? '$' : '')
        this.output = ''
        return output
    }
}
function Encoder ( ) { var skip = 0 // how many bits we will skip from the first byte var bits = 0 // 5 high bits, carry from one byte to the next this . output = '' // Read one byte of input // Should not really be used except by "update" this . readByte = function ( byte ) { // coerce the byte to an int if ( typeof byte == 'string' ) byte = byte . charCodeAt ( 0 ) if ( skip < 0 ) { // we have a carry from the previous byte bits |= ( byte >> ( - skip ) ) } else { // no carry bits = ( byte << skip ) & 248 } if ( skip > 3 ) { // not enough data to produce a character, get us another one skip -= 8 return 1 } if ( skip < 4 ) { // produce a character this . output += alphabet [ bits >> 3 ] skip += 5 } return 0 } // Flush any remaining bits left in the stream this . finish = function ( check ) { var output = this . output + ( skip < 0 ? alphabet [ bits >> 3 ] : '' ) + ( check ? '$' : '' ) this . output = '' return output } }
A streaming encoder

var encoder = new base32.Encoder()
var output1 = encoder.update(input1)
var output2 = encoder.update(input2)
var lastoutput = encode.update(lastinput, true)
A streaming encoder