在C#中的Java MessageDigest类 [英] Java MessageDigest class in C#

查看:3797
本文介绍了在C#中的Java MessageDigest类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一定的一块用Java做encrytion逻辑在C#$ B $转换B中的Java代码片断如下:

I require a certain piece of encrytion logic done in Java to be converted in C# the java code snippet is as follows.

会是什么C#相当于为更新(),摘要和复位功能?

What would be the C# equivalent for the update() , Digest and reset functions ?

推荐答案

在C#中,类的 的HashAlgorithm

In C#, the class is HashAlgorithm.

更新等效要么是 TransformBlock(.. 。) TransformFinalBlock(...),最后的块版本被称为后(也可以使用空的输入),你可以调用哈希属性,会给你的摘要值。

The equivalent to update is either TransformBlock(...) or TransformFinalBlock(...), after the final block version is called (you can also use an empty input) you can call the Hash property that will give you the digest value.

的HashAlgorithm 很可能是可重复使用的最后一块被称为后(这意味着它是复位下次呼叫时间 TransformBlock 的),你可以仔细检查,如果你的 HashAlogrithm 支持通过检查属性 CanReuseTransform 重用的。

HashAlgorithm is likely to be reusable after final block is called (which means it is reset for the next time you call TransformBlock), you can double check if your HashAlogrithm supports reusing at all by checking the property CanReuseTransform.

等同于你的重置()/摘要()的组合是一个行字节[] ComputerHash(字节[])

The equivalent to your reset()/digest() combo is a one line byte[] ComputerHash(byte[]).

这篇关于在C#中的Java MessageDigest类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆