문제

As seen in RFC2289 (S/KEY), there is a list of words that must be used when converting the hexadecimal string into a readable format.

How would i go about doing so?

The RFC mentions:

The one-time password is therefore converted to, and accepted as, a sequence of six short (1 to 4 letter) English words. Each word is chosen from a dictionary of 2048 words; at 11 bits per word, all one-time passwords may be encoded.

Read more: http://www.faqs.org/rfcs/rfc1760.html#ixzz0fu7QvXfe

Does this mean converting a hex into decimal and then using that as an index for an array of words. The other thing it could be is using a text encoding e.g. 1111 might equal dog in UTF-8 encoding

thanks in advance for your help!

도움이 되었습니까?

해결책

There's no need to convert to decimal. If your hex value is a string, just convert it to a number (for example, with Integer.valueOf(value, 16)). Then use that number to look up the word. If you can store the whole dictionary in memory, use the number as the index. If you can't store it in memory, use it to control how far into the dictionary file you look (if every item is on a separate line, read that many lines into the file). If you've got a database somewhere, use the number as the table's key and select by key.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top