Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- ///
- /// AUTHOR: Gordon Kyle Wallace, "Krythic".
- ///
- /// This function is the conceptual equivalent to .NET String.GetHashCode().
- /// The only difference is that this function is platform independent,
- /// and is not corrupted by the faggotry of incompetent Microsoft Programmers.
- /// So the value will always remain the same across different computers
- /// and platforms. This will ensure that random number generation
- /// will always be the same, no matter the computer the code is run on.
- /// (But seriously, fuck anything but Windows)
- /// </summary>
- /// <param name="password"></param>
- /// <returns></returns>
- private static int GenerateSeed( string password )
- {
- char[] passwordCharacters = password.ToCharArray();
- int lastCharacterIndex = passwordCharacters.Length - 1;
- int first = 0x15051505;
- int second = first;
- int index = 0;
- while( index <= lastCharacterIndex )
- {
- char currentPasswordCharacter = passwordCharacters[ index ];
- char nextPasswordCharacter = ++index > lastCharacterIndex ? '\0' : passwordCharacters[ index ];
- first = ( ( ( first << 5 ) + first ) + ( first >> 0x1b ) ) ^ ( nextPasswordCharacter << 16 | currentPasswordCharacter );
- if( ++index > lastCharacterIndex ) break;
- currentPasswordCharacter = passwordCharacters[ index ];
- nextPasswordCharacter = ++index > lastCharacterIndex ? '\0' : passwordCharacters[ index++ ];
- second = ( ( ( second << 5 ) + second ) + ( second >> 0x1b ) ) ^ ( nextPasswordCharacter << 16 | currentPasswordCharacter );
- }
- return first + second * 0x5d588b65;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement