crypt.baseN

Classes


Public Protected Private

Global Functions

goog.crypt.baseN.arrayToString_(numberbase) 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.
Arguments:
number : Array.<number>
Array of digit values, least significant first.
base : string
Digits in the base.
Returns: string  Number as a string, most significant digit first.
code »
goog.crypt.baseN.recodeString(numberinputBaseoutputBase) 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.)
Arguments:
number : string
The number to convert.
inputBase : string
The numeric base the number is in (all digits).
outputBase : string
Requested numeric base.
Returns: string  The converted number.
code »
goog.crypt.baseN.stringToArray_(numberbase) !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.
Arguments:
number : string
The string to convert, most significant digit first.
base : string
Digits in the base.
Returns: !Array.<number>  Array of digit values, least significant digit first.
code »

Global Properties

goog.crypt.baseN.BASE_64 :
The more-known version of the BASE-64 encoding. Uses + and / characters.
Code »
goog.crypt.baseN.BASE_64_URL_SAFE :
URL-safe version of the BASE-64 encoding.
Code »
goog.crypt.baseN.BASE_BINARY :
Base-2, i.e. '01'.
Code »
goog.crypt.baseN.BASE_DECIMAL :
Base-10, i.e. '0123456789'.
Code »
goog.crypt.baseN.BASE_LOWERCASE_HEXADECIMAL :
Base-16 using lower case, i.e. '0123456789abcdef'.
Code »
goog.crypt.baseN.BASE_OCTAL :
Base-8, i.e. '01234567'.
Code »
goog.crypt.baseN.BASE_UPPERCASE_HEXADECIMAL :
Base-16 using upper case, i.e. '0123456789ABCDEF'.
Code »

Package crypt

Package Reference