积极答复者
win8 app中用MD5加密的字符串怎么解密会原来到数据?

问题
-
下面是我自己通过Md5将一个字符串加密的方法,我现在想从把这个MD5值str64string从新转回原来的strPath字符串,这里我没做密钥,不知道如何可以对它解密了,该如何做,求高人指点!
public String ConvertPathToMD5(String strPath)
{
IBuffer mybf = CryptographicBuffer.ConvertStringToBinary(strPath, BinaryStringEncoding.Utf8);
string strAgName = HashAlgorithmNames.Md5;HashAlgorithmProvider haprovider = HashAlgorithmProvider.OpenAlgorithm(strAgName);
IBuffer mybfData = haprovider.HashData(mybf);if (mybfData.Length != haprovider.HashLength)
{
throw new ArgumentNullException("this is null can not create the hash");
}
string str64string = CryptographicBuffer.EncodeToHexString(mybfData);
return str64string;
}
答案
-
- 已标记为答案 Billy-NuoYan 2013年5月7日 12:28
全部回复
-
Hi,
MD5被称作Hash算法又被称作摘要算法,顾名思义,MD5算法的作用是对一大段数据得到一个唯一的,不可逆的,并且即使内容有着最微小的改变那么也会变得完全不同的,长度固定的一串字符。这一串字符对于内容来说并没有特定的意义,它的意义是在于可以用这段字符来检验这部分内容是不是被修改过,比如你得到一个MD5字符串,一段内容,对内容做MD5算法得到新的摘要与原来的比较就可以得知是否被修改过。还有一个比较大的用处在于非对称加密速度慢但可靠性高,对称加密速度快但易破解。因此通常对大量数据加密会使用对称加密对数据加密,并对数据做摘要之后对摘要进行非对称加密或者是使用签名算法。
如果你要加密的话应该去看看对称加密算法,看看我以前写的这个:
Aaron
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help. -
Hi,
MD5是不可逆的。你用MD5码得不到原数据,MD5不是用来加密的。
Aaron
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help. -
- 已标记为答案 Billy-NuoYan 2013年5月7日 12:28