SteamKit2.CryptoHelper.JenkinsHash C# (CSharp) Method

JenkinsHash() public static method

Performs the Jenkins hash on an input byte array
public static JenkinsHash ( byte input ) : byte[]
input byte
return byte[]
        public static byte[] JenkinsHash( byte[] input )
        {
            using ( JenkinsHash jHash = new JenkinsHash() )
            {
                byte[] hash = jHash.ComputeHash( input );
                Array.Reverse( hash );

                return hash;
            }
        }

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Gets an auth server list for a specific username.
        /// </summary>
        /// <param name="userName">The username.</param>
        /// <returns>A list of servers on success; otherwise, <c>null</c>.</returns>
        public IPEndPoint[] GetAuthServerList(string userName)
        {
            userName = userName.ToLower();

            byte[] userHash = CryptoHelper.JenkinsHash(Encoding.ASCII.GetBytes(userName));
            uint   userData = BitConverter.ToUInt32(userHash, 0) & 1;

            TcpPacket packet = base.GetRawServerList(ESteam2ServerType.ProxyASClientAuthentication, NetHelpers.EndianSwap(userData));

            if (packet == null)
            {
                return(null);
            }

            DataStream ds = new DataStream(packet.GetPayload(), true);

            ushort numAddrs = ds.ReadUInt16();

            IPEndPoint[] serverList = new IPEndPoint[numAddrs];
            for (int x = 0; x < numAddrs; ++x)
            {
                IPAddrPort ipAddr = IPAddrPort.Deserialize(ds.ReadBytes(6));

                serverList[x] = ipAddr;
            }

            return(serverList);
        }