nl_tokens: Encode a name ( a base32 string ) to a number .
pl_tokens: function encodeName128 ( name ) { if ( typeof name !== 'string' ) throw new TypeError ( 'name parameter is a required string' ) ; if ( name . length > 21 ) throw new TypeError ( 'A name can be up to 21 characters long' ) ; let bitstr = '' ; for ( let i = 0 ; i < 21 ; i ++ ) { // process all 64 bits (even if name is short) const c = i < name . length ? charidx128 ( name [ i ] ) : 0 ; let bits = Number ( c ) . toString ( 2 ) ; if ( bits . length > 6 ) { throw new TypeError ( 'Invalid name ' + name ) ; } bits = '0' . repeat ( 6 - bits . length ) + bits ; bitstr = bits + bitstr ; } let cutSize = 4 ; if ( name . length <= 5 ) { bitstr += "00" cutSize = 4 } else if ( name . length <= 10 ) { bitstr += "01" cutSize = 8 } else if ( name . length <= 15 ) { bitstr += "10" cutSize = 12 } else { bitstr += "11" cutSize = 16 } let bn = <mask> BN ( bitstr , 2 ) ; // bn = bn.toTwos(128); return bn . toArrayLike ( Buffer , 'le' , 128 / 8 / 16 * cutSize ) ; }