SHA1纯文本? C#.NET [英] SHA1 Plain text? C#.NET
问题描述
我使用C#和SHA1计算为一个字符串。我的问题是,这会总会产生明文0-1和A-Z?或者,它会产生具有特殊字符呢? ?我的意思是ComputeHash功能,这里将总是返回纯文本
I am using C# and calculating SHA1 for a string. My question is that will this always produce plain text 0-1 and A-Z ? Or it will produce has with special characters too ? I mean is ComputeHash function here will return always plain text ?
SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
string receivedValue = BitConverter.ToString(sha1.ComputeHash(to_be_hash)).Replace("-", "");
不知道,但我想,只有当它应该产生特殊字符其转换为基64。
Not sure but I think it should generate special character only if its converted to Base 64 .
推荐答案
这是一个十六进制字符串,所以只有0-9和AF。
It's a hex string, so only 0-9 and A-F.
其实这只是一个字节数组,但你使用字符串BitConverter.ToString(字节[])
办法把它变成在对两个十六进制字符串,由分离 - (短划线)
Actually it's just a byte array, but you use the string BitConverter.ToString(byte[])
method to turn it into a hex-string in pairs of two separated by a - (dash).
进制只包含:0,1,2,3,4,5,6,7,8,9,A,b,C,D中,E,F 16的选择,一对二的那些将代表一个字节(16×16 = 2 ^ 8 = 256,是一个单字节)。
Hexadecimal only contains: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. 16 options, a pair of two of those will represent a single byte (16*16 = 2^8 = 256, is a single byte).
这篇关于SHA1纯文本? C#.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!