Вопрос

I have this code to generate a random key.

new BigInteger(130, random).toString(32);

From what I understand, the first part of the code will create a 130 bit, random, integer. Then, the .toString(int radix) method will be called on it and the number will be converted to an alpha-numeric string.

What I can't understand is which alphabet is used for the characters; in other words, which key is mapped to which character?

Note: I looked for how a Base 32 conversion can happen, but I couldn't come up with anything useful since it doesn't seem to be a unique method to do that.

Это было полезно?

Решение

The javadoc says:

" The digit-to-character mapping provided by Character.forDigit is used, and a minus sign is prepended if appropriate.".

And the latter javadoc says:

" If the digit is less than 10, then '0' + digit is returned. Otherwise, the value 'a' + digit - 10 is returned."

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top