- public static string MD5(string file)
- {
- if (System.IO.File.Exists (file))
- {
- System.IO.FileStream st=null;
- try
- {
- System.Security.Cryptography.MD5CryptoServiceProvider check;
- st= System.IO.File.Open (file,System.IO.FileMode.Open,System.IO.FileAccess.Read);
- check = new System.Security.Cryptography.MD5CryptoServiceProvider();
- byte[] somme = check.ComputeHash (st);
- string ret = "";
- foreach (byte a in somme)
- {
- if (a<16)
- ret += "0" + a.ToString ("X");
- else
- ret += a.ToString ("X");
- }
- return ret ;
- }
- catch
- {
- throw;
- }
- finally
- {
- if ( st != null)
- st.Close();
- }
- }
- else
- {
- throw new System.IO.FileNotFoundException ("Fichier non trouvé.",file);
- }
- }
public static string MD5(string file)
{
if (System.IO.File.Exists (file))
{
System.IO.FileStream st=null;
try
{
System.Security.Cryptography.MD5CryptoServiceProvider check;
st= System.IO.File.Open (file,System.IO.FileMode.Open,System.IO.FileAccess.Read);
check = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] somme = check.ComputeHash (st);
string ret = "";
foreach (byte a in somme)
{
if (a<16)
ret += "0" + a.ToString ("X");
else
ret += a.ToString ("X");
}
return ret ;
}
catch
{
throw;
}
finally
{
if ( st != null)
st.Close();
}
}
else
{
throw new System.IO.FileNotFoundException ("Fichier non trouvé.",file);
}
}