OTP 或 S/KEY - 将十六进制字符串转换为 6 个可读字
如 RFC2289 (S/KEY) 中所示,将十六进制字符串转换为可读格式时必须使用一系列单词。
我该怎么做呢?
RFC 提到:
因此一次性密码是 转换为并接受为 六个短序列(1 到 4 个字母) 英语单词。每个词都被选中 来自 2048 个单词的词典; 11点 每个字位数,所有一次性密码 可能会被编码。
这是否意味着将十六进制转换为十进制,然后将其用作单词数组的索引。另一件可能的事情是使用文本编码,例如 1111 可能等于 UTF-8 编码中的狗,
提前感谢您的帮助!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无需转换为十进制。如果您的十六进制值是字符串,只需将其转换为数字(例如,使用
Integer.valueOf(value, 16)
)。然后使用该数字来查找该单词。如果可以将整个字典存储在内存中,请使用数字作为索引。如果您无法将其存储在内存中,请使用它来控制您查看字典文件的深度(如果每个项目都位于单独的行上,则将那么多行读入文件中)。如果您在某个地方有数据库,请使用数字作为表的键并按键进行选择。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.