Esempio n. 1
0
        public SecureSession CreateSession(IPAddress clientIp)
        {
            var sess = new SecureSession(clientIp);

            // At some point Sessions was a List
            //Sessions.Add(sess);

            // We could, in theory, have a collision of sessions.
            // I'm going to take that risk.
            // We need to hash(hashed_sequence + session_id)
            // Both of these are byte arrays, so we need to build a bigger byte array.
            // Then clear that byte array once we no longer need it.
            byte[] hashedId = HashUtils.HashBytes(HashUtils.ConcatByteArrays(_sequence, sess.SessionId));
            Sessions.TryAdd(HashUtils.ByteArrayToHexString(hashedId), sess);
            HashUtils.ClearByteArray(hashedId);
            return(sess);
        }