开发者

OTP S/KEY One Time password - Folding MD5 Digest output

开发者 https://www.devze.com 2022-12-20 10:37 出处:网络
Im trying to create a one time 开发者_如何学Pythonpassword generator for a phone. In the RFC2289 it specifies that i must fold the output of the MD5, i\'m using bouncy castle MD5 and i cant work out h

Im trying to create a one time 开发者_如何学Pythonpassword generator for a phone. In the RFC2289 it specifies that i must fold the output of the MD5, i'm using bouncy castle MD5 and i cant work out how to fold the byte array output.

for (int i = 0; i < 8; i++)
{
    md5[i] ^= md5[i+8];
}

This is what i have so far


Probably, you want this:

for (int i = 0; i < 8; ++i)
    md5[i] ^= md5[i + 8];
return Arrays.copyOf(md5, 8);

This way, only the first 64 bits (which are used by OTP) is returned.

0

精彩评论

暂无评论...
验证码 换一张
取 消