Home

# Library goog.crypt.baseN

Function Summary
| `arrayToString_(?Array.<number> number, string base) ⇒ string` Converts an array representation of a number to a string. More precisely, the elements of the input array are indices into the base, which is represented as a string, which can either be user defined or one of the BASE_xxx constants. Throws an Error if the number contains a digit which is outside the range 0 ... base.length - 1.

`recodeString(string number, string inputBase, string outputBase) ⇒ string`

Converts a number from one numeric base to another. The bases are represented as strings, which list allowed digits. Each digit should be unique. The bases can either be user defined, or any of goog.crypt.baseN.BASE_xxx. The number is in human-readable format, most significant digit first, and is a non-negative integer. Base designators such as $, 0x, d, b or h (at end) will be interpreted as digits, so avoid them. Leading zeros will be trimmed. Note: for huge bases the result may be inaccurate because of overflowing 64-bit doubles used by JavaScript for integer calculus. This may happen if the product of the number of digits in the input and output bases comes close to 10^16, which is VERY unlikely (100M digits in each base), but may be possible in the future unicode world. (Unicode 3.2 has less than 100K characters. However, it reserves some more, close to 1M.)

| `stringToArray_(string number, string base) ⇒ ?Array.<number>` Converts a string representation of a number to an array of digit values. More precisely, the digit values are indices into the number base, which is represented as a string, which can either be user defined or one of the BASE_xxx constants. Throws an Error if the number contains a digit not found in the base.