Ejemplo n.º 1
0
        public static long HashToLong(string data)
        {
            uint hash1;
            uint hash2;

            PerfectHash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(data.ToUpper(CultureInfo.InvariantCulture)), seed1: 0, seed2: 0, hash1: out hash1, hash2: out hash2);
            long hashedValue = ((long)hash1 << 32) | (long)hash2;

            return(hashedValue);
        }
        public static short HashToShort(string data)
        {
            uint hash1;
            uint hash2;

            string upper = data.ToUpper(CultureInfo.InvariantCulture);

            PerfectHash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(upper), seed1: 0, seed2: 0, hash1: out hash1, hash2: out hash2);
            long hashedValue = hash1 ^ hash2;

            return((short)hashedValue);
        }
Ejemplo n.º 3
0
        public static long HashToLong(string data)
        {
            uint hash1;
            uint hash2;

#if NETSTANDARD1_3
            string upper = data.ToUpper();
#else
            string upper = data.ToUpper(CultureInfo.InvariantCulture);
#endif
            PerfectHash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(upper), seed1: 0, seed2: 0, hash1: out hash1, hash2: out hash2);
            long hashedValue = ((long)hash1 << 32) | (long)hash2;

            return(hashedValue);
        }
Ejemplo n.º 4
0
        public static short HashToShort(string data)
        {
            uint hash1;
            uint hash2;

#if WINDOWS_UWP || NETSTANDARD1_3
            string upper = data.ToUpper();
#else
            string upper = data.ToUpper(CultureInfo.InvariantCulture);
#endif
            PerfectHash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(upper), seed1: 0, seed2: 0, hash1: out hash1, hash2: out hash2);
            long hashedValue = hash1 ^ hash2;

            return((short)hashedValue);
        }
Ejemplo n.º 5
0
        public static long HashToLong(string data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data), "The data string cannot be null.");
            }
            uint hash1;
            uint hash2;

            string upper = data.ToUpper(CultureInfo.InvariantCulture);

            PerfectHash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(upper), seed1: 0, seed2: 0, hash1: out hash1, hash2: out hash2);
            long hashedValue = ((long)hash1 << 32) | (long)hash2;

            return(hashedValue);
        }