private string GetHashFromModel(DbConnection connection) { var sql = GetSqlFromModel(connection); string hash = HashCreator.CreateHash(sql); return(hash); }
public void HashTestSHA256(string elvart, string szoveg) { extTest = extReport.CreateTest("SHA256 teszt"); HashCreator hashsha256 = new HashCreator(); var sut = hashsha256.CreateHash(HashType.SHA256, szoveg, true); Assert.AreEqual(elvart, sut); extTest.Log(Status.Pass, "SHA256 teszt rendben"); }
public void HashTestMD5(string elvart, string szoveg) { extTest = extReport.CreateTest("MD5 hash tesztelése"); HashCreator hashmd5 = new HashCreator(); var sut = hashmd5.CreateHash(HashType.MD5, szoveg); Assert.AreEqual(elvart, sut); extTest.Log(Status.Pass, "MD5 hash teszt rendben."); }
static void Main(string[] args) { string szoveg = "Valami szöveg"; //22e67b691bcc1bb1c806364fb660294e byte[] szovegbytes = new UTF8Encoding().GetBytes(szoveg); MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); var hash = md5.ComputeHash(szovegbytes); StringBuilder hashmd5 = new StringBuilder(); for (int i = 0; i < hash.Length; i++) { hashmd5.Append(hash[i].ToString("x2")); } Console.WriteLine(hashmd5); byte[] fajladatok = File.ReadAllBytes("toyota.jpg"); hash = md5.ComputeHash(fajladatok); StringBuilder hashfajlmd5 = new StringBuilder(); for (int i = 0; i < hash.Length; i++) { hashfajlmd5.Append(hash[i].ToString("x2")); } //3c10c2eabdbda72710357ba04f8a2941 Console.WriteLine(hashfajlmd5.ToString()); HashCreator hashcmd5 = new HashCreator(); Console.WriteLine(hashcmd5.CreateHash(HashType.MD5, "Valami szöveg")); Console.WriteLine(hashcmd5.CreateHash(HashType.MD5, @"d:\toyota.jpg")); Console.ReadKey(); }
private void MakeHash(string szoveg) { if (selectmd5.IsChecked == true) { hashszoveg.Text = hash.CreateHash(HashType.MD5, szoveg); } else if (selectsha1.IsChecked == true) { hashszoveg.Text = hash.CreateHash(HashType.SHA1, szoveg); } else if (selectsha256.IsChecked == true) { hashszoveg.Text = hash.CreateHash(HashType.SHA256, szoveg); } else if (selectsha384.IsChecked == true) { hashszoveg.Text = hash.CreateHash(HashType.SHA384, szoveg); } else { hashszoveg.Text = hash.CreateHash(HashType.SHA512, szoveg); } }
public void truncatedHashTest() { string userString = "test_password"; string goodHash = creator.CreateHash(userString); string badHash = ""; int badHashLength = goodHash.Length; do { badHashLength -= 1; badHash = goodHash.Substring(0, badHashLength); bool raised = false; try { creator.VerifyPassword(userString, badHash); } catch (InvalidHashException) { raised = true; } if (!raised) { Console.WriteLine("Truncated hash test: FAIL " + "(At hash length of " + badHashLength + ")"); System.Environment.Exit(1); } // The loop goes on until it is two characters away from the last : it // finds. This is because the PBKDF2 function requires a hash that's at // least 2 characters long. This will be changed once exceptions are // implemented. } while (badHash[badHashLength - 3] != ':'); Console.WriteLine("Truncated hash test: pass"); }
public Dictionary <string, string> CreateHeaders(string dataString, bool isFull = true) { string timeStamp = GetTimestamp().ToString(); Dictionary <string, string> headers = new Dictionary <string, string>(); List <string> values = new List <string>(); headers.Add("Timestamp", timeStamp); values.Add(timeStamp); if (isFull) { headers.Add("SessionID", AccountServices.ActiveUser.SessionId); values.Add(AccountServices.ActiveUser.SessionId); string nonce = GenerateNonce(); headers.Add("Nonce", nonce); values.Add(nonce); } values.Add(dataString); headers.Add("Hash", hashCreator.CreateHash(values.ToArray())); return(headers); }
public void CreateHashTest() { string result = HashCreator.CreateHash("Test,Test,Test"); Assert.AreEqual("kMbs8GbjyafvacMkuACV+tDtaoM9ii8y7pxi8AjgfcFincyIrDiD6R8kTiO5lupnmcYqZMUHtQk144aV3HTTCg==", result); }