1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace cstest
- {
- static class Program
- {
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main()
- {
- string md5 = "AT中国123";
- byte[] sss = Encoding.UTF8.GetBytes(md5);
- string ss2 = System.Text.Encoding.GetEncoding("gb2312").GetString(sss);
-
- byte[] result = new byte[32];
- // result = Encoding.UTF8.GetBytes(md5);
- IntPtr intptr = Marshal.AllocHGlobal(32);
- int len = 32;
- if ( 0 == GetStringMD5(ss2, intptr, len) )
- //if (0 == GetFileMD5(@"D:\0.dat", intptr, len))
- {
- System.Runtime.InteropServices.Marshal.Copy(intptr, result, 0, 32);
- string md52 = Encoding.Default.GetString(result);
- }
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new Form1());
- }
- #region
- [DllImport("lyfzMD5.dll", EntryPoint = "GetStringMD5")]
- public static extern int GetStringMD5(string input, IntPtr result, int len);
- [DllImport("lyfzMD5.dll", EntryPoint = "GetFileMD5")]
- public static extern int GetFileMD5(string filepath, IntPtr result, int len);
- #endregion
- }
- }
|