[转载]MD5算法之C#程序 MD5算法描述[5]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 austinlei 的 blog

      hexstring += b.tostring(format);
    }
    return hexstring;
  }

  public static string mdstring(string message){
    char[] c = message.tochararray();
    byte[] b = new byte[c.length];
    for(int i=0;i<c.length;i++){
      b[i]=(byte)c[i];
    }
    byte[] digest = md5array(b);
    return arraytohexstring(digest,false);
  }
  public static string mdfile(string filename){
    filestream fs=file.open(filename,filemode.open,fileaccess.read);
    byte[] array=new byte[fs.length];
    fs.read(array,0,(int)fs.length);
    byte[] digest = md5array(array);
    fs.close();
    return arraytohexstring(digest,false);
  }

  public static string test(string message){
    return "rnmd5 (""+message+"") = " + md5.mdstring(message);
  }
  public static string testsuite(){   
    string s = "";
    s+=test("");
    s+=test("a");
    s+=test("abc");
    s+=test("message digest");
    s+=test("abcdefghijklmnopqrstuvwxyz");
    s+=test("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789");
    s+=test("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
    return s;   
  }
}
[/code]

本文关键:[转载]MD5算法之C#程序 MD5算法描述
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top