Otp.AbstractConnection.genDigest C# (CSharp) Method

genDigest() protected method

protected genDigest ( int challenge, System cookie ) : byte[]
challenge int
cookie System
return byte[]
        protected internal virtual byte[] genDigest(int challenge, System.String cookie)
        {
            int i;
            long ch2;
            
            if (challenge < 0)
            {
                ch2 = 1L << 31;
                ch2 |= (long) (challenge & 0x7FFFFFFFL);
            }
            else
            {
                ch2 = (long) challenge;
            }
            System.Security.Cryptography.MD5CryptoServiceProvider context 
                = new System.Security.Cryptography.MD5CryptoServiceProvider();

            byte[] tmp = context.ComputeHash(System.Text.Encoding.UTF8.GetBytes(cookie+System.Convert.ToString(ch2)));
            byte[] res = new byte[tmp.Length];
            for (i = 0; i < tmp.Length; ++i)
            {
                res[i] = (byte) (tmp[i] & 0xFF);
            }
            return res;
        }