Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top