我试着解密我的文件,但我有一条消息
/Applications/XAMPP/xamppfiles/htdocs/test/test.php中的
警告: mcrypt_cbc()函数.mcrypt_cbc:密钥的大小对于第32行的这个算法来说太大了
<?php
$key = md5("Test");
//fonction decode
function decode($pass_coder)
{
$pass_str = mcrypt_ecb(MCRYPT_TripleDES,$key, $pass_coder, MCRYPT_DECRYPT);
return $pass_str;
}
echo (decode($pass_coder));
>
我使用这个函数加密我的文件。
public void Encrypt(XmlDocument doc, string rootTag, string password)
{
// Transform password to MD5 hash value
ASCIIEncoding enc = new ASCIIEncoding();
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] md5val = md5.ComputeHash(enc.GetBytes(password));
// Create key and use MD5 hash value as key
TripleDES key = TripleDESCryptoServiceProvider.Create();
key.Key = md5val;
// Encrypt data
EncryptedXml ec = new EncryptedXml(doc);
ArrayList list = new ArrayList();
foreach (XmlElement el in doc.GetElementsByTagName(rootTag))
{
byte[] data = ec.EncryptData(el, key, false);
EncryptedData ed = new EncryptedData();
ed.Type = EncryptedXml.XmlEncElementUrl;
ed.EncryptionMethod = new EncryptionMethod(EncryptedXml
.XmlEncTripleDESUrl);
ed.CipherData = new CipherData();
ed.CipherData.CipherValue = data;
list.Add(new object[] { el, ed });
}
// Write encrypted data to XML document
foreach (object[] obj in list)
EncryptedXml.ReplaceElement((XmlElement)obj[0], (
EncryptedData)obj[1], false);
}
发布于 2011-07-15 02:44:42
也许我已经完全错过了你的问题,但我怀疑你想做的,是不可能的。您无法解密使用MD5散列的内容。您可以比较并最终得出这样的结论: string_xxx == string_yyy如果使用相同的盐时MD5哈希匹配.
https://stackoverflow.com/questions/6704841
复制相似问题