Reversing a md5 hash algorithm in C#
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1471654/reversing-an-md5-hash">Reversing an MD5 Hash</a>  </p>
</blockquote>



<p>Given this method in c#</p>

<pre><code>public string CalculateFileHash(string filePaths) {
    var csp = new MD5CryptoServiceProvider();
    var pathBytes = csp.ComputeHash(Encoding.UTF8.GetBytes(filePaths));
    return BitConverter.ToUInt64(pathBytes, 0).ToString();
}
</code></pre>

<p>how would one reverse this process with a "DecodeFileHash" method?</p>

<pre><code>var fileQuery = "fileone.css,filetwo.css,file3.css";
var hashedQuery = CalculateFileHash(fileQuery); // e.g. "23948759234"
var decodedQuery = DecodeFileHash(hashedQuery); // "fileone.css,filetwo.css,file3.css"
</code></pre>

<p>where decodedQuery == fileQuery in the end.</p>

<p>Is this even possible? If it isn't possible, would there by any way to generate a hash that I could easily decode?</p>

<p>Edit: So just to be clear, I just want to compress the variable "fileQuery" and decompress fileQuery to determine what it originally was. Any suggestions for solving that problem since hashing/decoding is out?</p>

<p>Edit Again: just doing a base64 encode/decode sounds like the optimal solution then.</p>

<pre><code>public string EncodeTo64(string toEncode) {
    var toEncodeAsBytes = Encoding.ASCII.GetBytes(toEncode);
    var returnValue = System.Convert.ToBase64String(toEncodeAsBytes);
    return returnValue;
}

public string DecodeFrom64(string encodedData) {
    var encodedDataAsBytes  = System.Convert.FromBase64String(encodedData);
    var returnValue = Encoding.ASCII.GetString(encodedDataAsBytes);
    return returnValue;
}
</code></pre>
