private string GetUrl() { string ticks = DateTime.Now.Ticks.ToString(); string hash = HashCreator.Create(ticks, _marvelConfig.PublicKey, _marvelConfig.PrivateKey); return(string.Concat(_marvelConfig.BaseURL, $"comics?ts={ticks}&apikey={_marvelConfig.PublicKey}&hash={hash}")); }
private string GetHashFromModel(DbConnection connection) { var sql = GetSqlFromModel(connection); string hash = HashCreator.CreateHash(sql); return(hash); }
public void ComputeHashes() { var hash = new HashCreator(); Md5Hash = hash.CreateMd5Hash(FilePath); Sha1Hash = hash.CreateSha1Hash(FilePath); Sha256Hash = hash.CreateSha256Hash(FilePath); }
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."); }
public void Version_1_164() { string payload = "[{\"__class__\":\"ServerRequest\",\"requestData\":[],\"requestClass\":\"StartupService\",\"requestMethod\":\"getData\",\"requestId\":1}]"; string userkey = "lNQgc3zbl3VBLZ-8NXMtFtkm"; string secret = "XJ18e9tTgdV5pP6TlHBUah/7sYLewDfTGdoe0Z/bPI+S882zTj8DJHftS19opvb6jSWnbgaJmwAvJDd7m1pLrQ=="; HashCreator hashCreator = new HashCreator(_settings); string signature = hashCreator.GetMd5Hash(userkey + secret + payload); Assert.AreEqual("7047085c4f", signature.Substring(0, 10)); }
public void Version_1_145_2() { string payload = "[{\"__class__\":\"ServerRequest\",\"requestData\":[],\"requestClass\":\"StartupService\",\"requestMethod\":\"getData\",\"requestId\":1}]"; string userkey = "r7XrEknlQw50DdNDiy_bs21V"; string secret = "5ojZ7ltWda/CMrY6IhVwdvAMYK9Gy5QLIdrSDitg9/ugY9y8YL8haQp7ZR6EXZo182gNenXv0Er4F2p1myI0MA=="; HashCreator hashCreator = new HashCreator(_settings); string signature = hashCreator.GetMd5Hash(userkey + secret + payload); Assert.AreEqual("d3809d0e2c", signature.Substring(0, 10)); }
public void Version_1_143() { string payload = "[{\"__class__\":\"ServerRequest\",\"requestData\":[],\"requestClass\":\"StartupService\",\"requestMethod\":\"getData\",\"requestId\":1}]"; string userkey = "0TmPDOZ7ciiZjOnusowfMG3-"; string secret = "Rw7oeLIP29HTVWjgS3NG6UzoyfIoEtwUR3pY/if76FdLOZHUPRLGHVDRCkdk4zijAqv4YGXBtIbKKnDCn7/8+A=="; HashCreator hashCreator = new HashCreator(_settings); string signature = hashCreator.GetMd5Hash(userkey + secret + payload); Assert.AreEqual("94bfbfa0ce", signature.Substring(0, 10)); }
public void Version_1_144() { string payload = "[{\"__class__\":\"ServerRequest\",\"requestData\":[],\"requestClass\":\"StartupService\",\"requestMethod\":\"getData\",\"requestId\":1}]"; string userkey = "vpGv01DRo23aAJMqi35PjjcH"; string secret = "X2hSCLmVfPKbmWIMm88CfEokCPVIfhV1cooHcF4yopCUkfEQJ6IsaDWsZHkz1xTfWAOdWPn2Iwp6wbLmnJBElw=="; HashCreator hashCreator = new HashCreator(_settings); string signature = hashCreator.GetMd5Hash(userkey + secret + payload); Assert.AreEqual("5cd4cde2b0", signature.Substring(0, 10)); }
private string GetUrl(string url) { if (string.IsNullOrWhiteSpace(url)) { return(""); } string ticks = DateTime.Now.Ticks.ToString(); string hash = HashCreator.Create(ticks, _marvelConfig.PublicKey, _marvelConfig.PrivateKey); return(string.Concat(url, $"?ts={ticks}&apikey={_marvelConfig.PublicKey}&hash={hash}")); }
public void HashCreatorTest_Origin() { var settingsMock = new Mock <ISettings>(); settingsMock.SetupGet(x => x.Secret) .Returns("5ojZ7ltWda/CMrY6IhVwdvAMYK9Gy5QLIdrSDitg9/ugY9y8YL8haQp7ZR6EXZo182gNenXv0Er4F2p1myI0MA=="); settingsMock.SetupGet(x => x.Gateway) .Returns(@"https://hu2.forgeofempires.com/game/json?h=r7XrEknlQw50DdNDiy_bs21V"); var hashCreator = new HashCreator(settingsMock.Object); var signature = hashCreator.GetSignature("[{\"__class__\":\"ServerRequest\",\"requestData\":[],\"requestClass\":\"StartupService\",\"requestMethod\":\"getData\",\"requestId\":1}]"); Assert.AreEqual("d3809d0e2c", signature); }
public void UpdatePassword(User user) { try { var dbManager = new DbManager(); dbManager.UpdatePassword(user.UserName, HashCreator.Create(user.Password + HashCreator.Key + user.UserName)); } catch (Exception exception) { LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception, System.Reflection.MethodBase.GetCurrentMethod().Name); throw new ApplicationException("Password updating failed"); } }
public void TestBcryptVerify() { HashCreator h = new HashCreator(); string hashe = h.HashMDP(""); Assert.AreEqual(true, h.checkMotDePasse("", "$2a$10$cCCVc6odqxDpcmEsnqDYM.dAysJsC0PYxifFSUU8bAPuwjmSNX5GG")); Assert.AreEqual(false, h.checkMotDePasse("", "$2a$10$wffrNsHbvNJOtilp0U08q.rcYKwQuc9swHns9GE8AblaIMxlghvIK")); Assert.AreEqual(false, h.checkMotDePasse("", "$2a$10$eB4ot372dJty1O3HnKQcZeOITUiwcpQCDHw3McIbfOSqRVyRu.EJe")); HashCreator h2 = new HashCreator(); Assert.AreEqual(true, h2.checkMotDePasse("", hashe)); }
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(); }
/// <summary> /// Constructor /// </summary> public MainWindow() { InitializeComponent(); LoadDictionnary(false, ""); // TODO: allow a change of the hashertype through an option or something. hashCreator = new HashCreator(hashDic, Hasher.HasherType.TOR); fileInArchiveBindingSource.DataSource = new SortableBindingList <FileInArchive>(); //Define functions that should be called to treat events //Needed because of cross thread calls OnNewExtractedEvent = TreatExtractionEvent; OnNewFileTableEvent = TreatFileTableEvent; OnNewFilenameTestEvent = TreatFilenameTestEvent; OnLabelsReset = LabelsTextReset; OnLabelUpdate = _LabelUpdate; OnMenuActivation = _MenuActivation; OnProgressBarVisibilityUpdate = _ProgressBarVisibilityUpdate; // Populate the system tree view TreeViewManager.PopulateSystemTreeNode(treeView_FileSystem); }
public AuthenticationDetails Login(User user) { try { var authenticationDetails = new AuthenticationDetails(); var dbManager = new DbManager(); authenticationDetails.Username = user.UserName; authenticationDetails.AuthKey = dbManager.UserLogin(user.UserName, HashCreator.Create(user.Password + HashCreator.Key + user.UserName)); if (!Utility.IsNullOrEmpty(authenticationDetails.AuthKey)) { authenticationDetails.LastSyncTime = Utility.ConvertLocalToUtc(Convert.ToDateTime(dbManager.GetLastSyncTime())).ToString(AppConstants.DateTimeFormat); authenticationDetails.LastLoginTime = dbManager.GetLastLoginTime(user.UserName); return(authenticationDetails); } return(null); } catch (Exception exception) { LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception, System.Reflection.MethodBase.GetCurrentMethod().Name); throw new ApplicationException("Opertaion failed due to some internal error"); } }
public MainWindow() { InitializeComponent(); hash = new HashCreator(); }
public void CreateHashTest() { string result = HashCreator.CreateHash("Test,Test,Test"); Assert.AreEqual("kMbs8GbjyafvacMkuACV+tDtaoM9ii8y7pxi8AjgfcFincyIrDiD6R8kTiO5lupnmcYqZMUHtQk144aV3HTTCg==", result); }
public void PHTestException_12() { HashCreator.GetHash(null); }
/// <summary> /// Fonction qui va vérifier le mot de passe d'un utilisateur /// </summary> /// <param name="mdp">Le mot de passe entré</param> /// <returns>Retourne vrai ou faux si le mot de passe correspond bien à ce qui est stocké en mémoire</returns> public bool verificationMotDePasse(string mdp) { HashCreator h = new HashCreator(); return(h.checkMotDePasse(mdp, MotDePasse)); }