public override int GetHashCode() { return(HashTool.Compute(ProjectId, TaskId, StartTime, EndTime)); }
// helper function to set cookies private void SetCookie(string cookieName, string cookieValue) { var cookieOption = new CookieOptions(); cookieOption.Expires = DateTime.Now.AddDays(1); Response.Cookies.Append(cookieName, HashTool.HashString(cookieValue), cookieOption); }
/// <summary> /// Create a transition which represent the state switch to another state,and add it to the transition list. /// </summary> /// <param name="fsmStateName">The state name</param> /// <param name="nextFSMStateName">The name of the next state</param> /// <param name="fsmTransitionConditionArray">Some transition conditions</param> public FSMTransition CreateFSMStateToAnotherFSMStateTransition(string fsmStateName, string nextFSMStateName, IFSMTransitionCondition[] fsmTransitionConditionArray) { //convert the state name to hash value,to improve performance string fsmStateNameHash = HashTool.StringToHash(fsmStateName); FSMState fsmState = null; bool fsmStateExist = m_FSMStateDic.TryGetValue(fsmStateNameHash, out fsmState); if (fsmStateExist == false) { Debug.LogErrorFormat("The fsmStateName:{0} is not exist", fsmStateName); return(null); } //convert the state name to hash value,to improve performance string nextFSMStateNameHash = HashTool.StringToHash(nextFSMStateName); FSMState nextFSMState = null; bool nextFSMStateExist = m_FSMStateDic.TryGetValue(nextFSMStateNameHash, out nextFSMState); if (nextFSMStateExist == false) { Debug.LogErrorFormat("The nextFSMStateName:{0} is not exist", nextFSMStateName); return(null); } return(fsmState.AddTransition(nextFSMState, fsmTransitionConditionArray)); }
/// <summary> /// Create each state switch to the given state's transition ,and add them to the transition list. /// </summary> /// <param name="nextFsmStateName">the state which them will switch to</param> /// <param name="fsmTransitionConditionArray">Some transition conditions</param> public void CreateAnyFSMStateToFSMStateTransition(string nextFsmStateName, IFSMTransitionCondition[] fsmTransitionConditionArray) { string nextFSMStateNameHash = HashTool.StringToHash(nextFsmStateName); FSMState nextFSMState = null; bool nextFSMStateExist = m_FSMStateDic.TryGetValue(nextFSMStateNameHash, out nextFSMState); if (nextFSMStateExist == false) { Debug.LogErrorFormat("The nextFSMStateName:{0} is not exist", nextFsmStateName); return; } foreach (KeyValuePair <string, FSMState> kv in m_FSMStateDic) { FSMState fsmState = kv.Value; if (fsmState != m_Entry && fsmState != m_Exit && fsmState != m_EndFSMState && fsmState != nextFSMState) { fsmState.AddTransition(nextFSMState, fsmTransitionConditionArray); } } }
/// <summary> /// Set the default state /// </summary> /// <param name="fsmStateName">The state name</param> public void SetDefaultState(string fsmStateName) { if (fsmStateName == null || fsmStateName == "") { Debug.LogError("the fsmStateName can not be null or Empty"); return; } FSMState fsmState = null; //convert the state name to hash value,to improve performance string fsmStateNameHash = HashTool.StringToHash(fsmStateName); bool exist = m_FSMStateDic.TryGetValue(fsmStateNameHash, out fsmState); if (exist == true) { this.m_DefaultFSMState = fsmState; } else { Debug.LogErrorFormat("The {0} is not exist", fsmStateName); } }
/// <summary> /// Set the end state /// </summary> /// <param name="fsmStateName">The state name</param> /// <param name="endStateToExitStateFSMTransitionConditionArray">Some conditions of endState switch to the exitState</param> public void SetEndState(string fsmStateName, IFSMTransitionCondition[] endStateToExitStateFSMTransitionConditionArray) { if (fsmStateName == null || fsmStateName == "") { Debug.LogError("the fsmStateName can not be null or Empty"); return; } FSMState fsmState = null; //convert the state name to hash value,to improve performance string fsmStateNameHash = HashTool.StringToHash(fsmStateName); bool exist = m_FSMStateDic.TryGetValue(fsmStateNameHash, out fsmState); if (exist == true) { this.m_EndFSMState = fsmState; m_Exit = new FSMExit("FSMExit"); AddState(m_Exit); this.m_EndFSMState.AddTransition(m_Exit, endStateToExitStateFSMTransitionConditionArray); } else { Debug.LogErrorFormat("The {0} is not exist", fsmStateName); } }
} // IsEqual // ---------------------------------------------------------------------- protected override int ComputeHashCode() { int hash = base.ComputeHashCode(); hash = HashTool.AddHashCode(hash, fullName); return(hash); } // ComputeHashCode
public void DateRange_HashCode_Test() { DateTime now = DateTime.Now; var ranges = new[] { new TimeRange(null, null), new TimeRange(null, now), new TimeRange(now, null), new TimeRange(now, now) }; foreach (var range in ranges) { var hash1 = HashTool.Compute(range.Start, range.End); var hash2 = HashTool.Compute(range.End, range.Start); Console.WriteLine("Range=[{0}], hash1=[{1}], hash2=[{2}]", range, hash1, hash2); if (Equals(range.Start, range.End) == false) { Assert.AreNotEqual(hash1, hash2); } else { Assert.AreEqual(hash1, hash2); Assert.AreNotEqual(0, hash1, "TimeRange=" + range); } } }
public void HashCode_Compute_Objects() { var now = DateTime.Now; var ranges = new[] { new TimeRange(null, null), new TimeRange(null, now), new TimeRange(now, null), new TimeRange(now, now) }; foreach (var range in ranges) { var hash1 = HashTool.Compute(range.Start, range.End); var hash2 = HashTool.Compute(range.End, range.Start); if (Equals(range.Start, range.End)) { hash1.Should().Be(hash2); hash1.Should().Not.Be(0); } else { hash1.Should().Not.Be.EqualTo(hash2); } } }
private static void QuickHashFile(DupItem file, int quickHashSize, ref long totalFileBytes, ref long totalReadBytes) { Interlocked.Add(ref totalFileBytes, file.Size); var hashSize = (int)Math.Min(file.Size, quickHashSize); using (var stream = File.Open(file.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { file.Tags = new byte[hashSize]; for (var i = 0; i < 3; i++) { var sectionSize = hashSize / 3; long position; if (i == 0) { position = 0; } else if (i == 1) { position = file.Size / 2 - sectionSize / 2; } else { position = file.Size - sectionSize; } stream.Seek(position, SeekOrigin.Begin); stream.Read(file.Tags, i * sectionSize, sectionSize); } file.QuickHash = HashTool.HashBytesText(file.Tags); if (file.Size <= hashSize) { file.Status = CompareStatus.Matched; } Interlocked.Add(ref totalReadBytes, hashSize); } }
public override int GetHashCode() { return(HashTool.Compute(Culture, WeekOfYearRule, StartOffset, EndOffset)); }
private void IncrementalHash(IGrouping <string, DupItem> quickHashGroup) { var groups = quickHashGroup.ToArray(); var first = groups.First(); var length = first.Size / BufferSize; if (length == 0) { length = 1; } var position = 0; for (var i = 0; i < length; i++) { position += BufferSize; foreach (var group in groups.GroupBy(g => i == 0 ? string.Empty : g.HashSections[i - 1])) { foreach (var groupFile in group) { if (groupFile.HashSections == null) { groupFile.HashSections = new List <string>(); } groupFile.HashSections.Add(HashTool.HashFile(groupFile.FileName, position, BufferSize)); } } } foreach (var groupFile in groups) { groupFile.FullHash = string.Join(string.Empty, groupFile.HashSections); } }
public dynamic resetPassword(int userID, string hashed) { if (!HashTool.VerifyMd5Hash(userID.ToString(), hashed)) { var err = new { err = "verify url format invalid" }; return(JsonTool.toJson(err)); } var user = (from p in db.users where p.userID.Equals(userID) select p).SingleOrDefault(); int status = (int)user.status; String baseURL = Request.RequestUri.GetLeftPart(UriPartial.Authority); String url = baseURL + "/front/showMsg.html"; String msgToken = ""; String htmlStr = ""; if (status.Equals(-1)) { msgToken = "userBanned"; } msgToken = "redirectToResetPasswordPage"; htmlStr = @" <!DOCTYPE html> <html lang='en'> <head> <title>plz w8</title> <meta charset = 'utf-8'> <meta name = 'viewport' content = 'width=device-width, initial-scale=1'> <link rel = 'stylesheet' href = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'> <script src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script> <script src = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'></script> </head> <body> <div class='container'> </div> <script> " + "sessionStorage.setItem('msgToken'," + "'" + msgToken + "'" + ");" + "sessionStorage.setItem('userID'," + "'" + user.userID + "'" + ");" + "sessionStorage.setItem('userEmail'," + "'" + user.email + "'" + ");" + "sessionStorage.setItem('userNickname'," + "'" + user.nickname + "'" + ");" + "window.location='" + url + "';" + @" </script> </body> </html>"; var response = new HttpResponseMessage(); response.Content = new StringContent(htmlStr); response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html"); return(response); }
} // IsEqual private int ComputeHashCode() { var hash = Red; hash = HashTool.AddHashCode(hash, Green); hash = HashTool.AddHashCode(hash, Blue); return(hash); } // ComputeHashCode
} // IsEqual // ---------------------------------------------------------------------- protected override int ComputeHashCode() { int hash = base.ComputeHashCode(); hash = HashTool.AddHashCode(hash, this.text); hash = HashTool.AddHashCode(hash, this.format); return(hash); } // ComputeHashCode
public void HashCode_Compute() { HashToolFixture.Entity entity = null; HashTool.Compute(entity).Should().Be(0); entity = new HashToolFixture.Entity(Guid.NewGuid(), "abc"); HashTool.Compute(entity).Should().Not.Be.EqualTo(0).And.Be(entity.GetHashCode()); }
public UserService() { currencyService = new CurrencyService(); roleService = new SiteRoleService(); userIncomeService = new UserIncomeService(); hashTool = new HashTool(); }
} // IsEqual // ---------------------------------------------------------------------- private int ComputeHashCode() { int hash = this.red; hash = HashTool.AddHashCode(hash, this.green); hash = HashTool.AddHashCode(hash, this.blue); return(hash); } // ComputeHashCode
} // IsEqual protected override int ComputeHashCode() { var hash = base.ComputeHashCode(); hash = HashTool.AddHashCode(hash, Text); hash = HashTool.AddHashCode(hash, _format); return(hash); } // ComputeHashCode
public UserService() { currencyService = new CurrencyService(); roleService = new SiteRoleService(); userIncomeService = new UserIncomeService(); ntService = new NotificationService(); hashTool = new HashTool(); }
private static void ProgressiveHashSection(long position, DupItem dupItem, int bufferSize, ref long totalReadBytes) { if (dupItem.HashSections == null) { dupItem.HashSections = new List <string>(); } dupItem.HashSections.Add(HashTool.HashFile(dupItem.FileName, position, bufferSize, bufferSize, out var readSize)); Interlocked.Add(ref totalReadBytes, readSize); }
public void md5() { string pwd = "1234"; HashTool hashTool = new HashTool(); Console.WriteLine( hashTool.Get( pwd, HashType.MD5_16 ) ); Console.WriteLine( hashTool.Get( pwd, HashType.MD5 ) ); }
public void md5() { string pwd = "1234"; HashTool hashTool = new HashTool(); Console.WriteLine(hashTool.Get(pwd, HashType.MD5_16)); Console.WriteLine(hashTool.Get(pwd, HashType.MD5)); }
public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(Department, User)); }
public override int GetHashCode() { return(HashTool.Compute(Calendar, YearBaseMonth, FirstDayOfWeek, Date1, Date2, Difference)); }
public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(TimeRange, IsException)); }
} // IsEqual private int ComputeHashCode() { var hash = ForegroundColor.GetHashCode(); hash = HashTool.AddHashCode(hash, BackgroundColor); hash = HashTool.AddHashCode(hash, FontFamily); hash = HashTool.AddHashCode(hash, FontSize); return(hash); } // ComputeHashCode
public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(Id, Name, GetType().FullName)); }
public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(GetType(), ReporterId, ReportDate)); }
/// <summary> /// Hash Code를 계산합니다. /// </summary> /// <returns></returns> public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(AssemblyName, Section, ResourceKey)); }
public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(Name)); }
} // IsEqual // ---------------------------------------------------------------------- private int ComputeHashCode() { int hash = foregroundColor.GetHashCode(); hash = HashTool.AddHashCode(hash, backgroundColor); hash = HashTool.AddHashCode(hash, fontFamily); hash = HashTool.AddHashCode(hash, fontSize); return(hash); } // ComputeHashCode
public void sha2() { string pwd = "1234"; HashTool hashTool = new HashTool(); Console.WriteLine( hashTool.Get( pwd, HashType.SHA384 ) ); // 9198EAB4 Console.WriteLine( hashTool.Get( pwd + "9198EAB4", HashType.SHA384 ) ); //Console.WriteLine( HashTool.GetSalt( 4 ) ); Console.WriteLine( ); Console.WriteLine( hashTool.GetBySalt( pwd, "9198EAB4", HashType.SHA384 ) ); }
public void getSalt() { string pwd = "aaa"; HashTool hashTool = new HashTool(); Console.WriteLine( "myMd5=" + hashTool.Get( pwd, HashType.MD5_16 ) ); Console.WriteLine( "myMd5=" + hashTool.Get( pwd, HashType.MD5 ) ); Console.WriteLine( "mySHA1=" + hashTool.Get( pwd, HashType.SHA1 ) ); Console.WriteLine( "mySHA2=" + hashTool.Get( pwd, HashType.SHA384 ) ); Console.WriteLine( "mySHA5=" + hashTool.Get( pwd, HashType.SHA512 ) ); Console.WriteLine( "GetRandomPassword="******"GetRandomPassword="******"GetSalt=" + hashTool.GetSalt( i ) ); } }
public UserService() { hashTool = new HashTool(); userIncomeService = new UserIncomeService(); }