C#HMAC到Java
我正在为下面的代码制作等效的java代码。但我可以创建一些返回encodeString相同结果的东西。我可以用什么Java类来实现相同的结果?
//Set the Hash method to SHA1
HMAC hash;
switch (validation)
{
case MachineKeyValidation.MD5:
hash = new HMACMD5();
break;
case MachineKeyValidation.SHA1:
default:
hash = new HMACSHA1();
break;
}
//Get the hash validation key as an array of bytes
hash.Key = HexToByte(validationKey);
//Encode the password based on the hash key and
//converts the encrypted value into a string
encodedString = Convert.ToBase64String(hash.ComputeHash(Encoding.Unicode.GetBytes(password)));
提前致谢!
:)
没有找到相关结果
已邀请:
2 个回复
郡豪靠暖
诉嘎归亮
您应该至少列出几个Sun提供商。如果没有,您可能需要下载一些安全库。