Beispiel #1
0
 public static byte[] Hash32(byte[] buffer)
 {
     System.Security.Cryptography.MD5 mD5 = System.Security.Cryptography.MD5.Create();
     byte[] result = mD5.ComputeHash(buffer);
     mD5.Dispose();
     return(result);
 }
Beispiel #2
0
        void win_OnGoClick(string id)
        {
            OpenDMS.Storage.Providers.EngineRequest request = new OpenDMS.Storage.Providers.EngineRequest();
            request.Engine              = _engine;
            request.Database            = _db;
            request.OnActionChanged    += new EngineBase.ActionDelegate(EngineAction);
            request.OnProgress         += new EngineBase.ProgressDelegate(Progress);
            request.OnComplete         += new EngineBase.CompletionDelegate(Complete);
            request.OnTimeout          += new EngineBase.TimeoutDelegate(Timeout);
            request.OnError            += new EngineBase.ErrorDelegate(Error);
            request.AuthToken           = _window.Session.AuthToken;
            request.RequestingPartyType = OpenDMS.Storage.Security.RequestingPartyType.User;

            Clear();

            System.IO.FileStream fs = new System.IO.FileStream("testdoc.txt", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None, 8192, System.IO.FileOptions.None);
            byte[] bytes            = System.Text.Encoding.ASCII.GetBytes("This is a test content file.");
            fs.Write(bytes, 0, bytes.Length);
            fs.Flush();
            fs.Close();
            fs.Dispose();

            fs = new System.IO.FileStream("testdoc.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.None, 8192, System.IO.FileOptions.None);
            System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
            byte[] data   = md5.ComputeHash(fs);
            string output = "";

            fs.Close();
            md5.Dispose();
            fs.Dispose();

            for (int i = 0; i < data.Length; i++)
            {
                output += data[i].ToString("x2");
            }

            OpenDMS.Storage.Providers.CreateVersionArgs versionArgs = new CreateVersionArgs()
            {
                VersionId = new VersionId(new ResourceId(id)),
                Extension = "txt",
                Metadata  = new Metadata(),
                Content   = new OpenDMS.Storage.Data.Content(bytes.Length, new OpenDMS.Storage.Data.ContentType("text/plain"), "testdoc.txt"),
                Md5       = output
            };

            WriteLine("Starting CreateNewVersion test...");
            _start = DateTime.Now;

            _engine.CreateNewVersion(request, versionArgs);
        }
Beispiel #3
0
        public static string MakeMD5(string oristring)
        {
            byte[] bs = System.Text.Encoding.UTF8.GetBytes(oristring);
            System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
            byte[] resultbs = md5.ComputeHash(bs);
            md5.Dispose();
            StringBuilder sb = new StringBuilder();

            foreach (var a in resultbs)
            {
                sb.Append(a.ToString("x2"));
            }
            return(sb.ToString());
        }
Beispiel #4
0
        public string CreateMD5(int roll, List <string> coins, string selection, string txID)
        {
            string allCoins = string.Empty;

            foreach (var coin in coins)
            {
                allCoins += String.Format("{0},", coin);
            }
            string concat = String.Concat(coins.Count.ToString(), "/", roll.ToString(), "|", allCoins, "|", selection, "|", txID);

            using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
            {
                byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(concat);
                byte[] hashBytes  = md5.ComputeHash(inputBytes);

                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < hashBytes.Length; i++)
                {
                    sb.Append(hashBytes[i].ToString("X2"));
                }
                md5.Dispose();
                return(sb.ToString());
            }
        }