/// <summary>
        /// Builds a SHA256 hash of the data contained in this <see cref="AuditEntry"/>.
        /// </summary>
        /// <param name="hashAlgorithm"><see cref="SupportedHashAlgorithm"/> to use for hashing data.</param>
        /// <returns>Hash byte array.</returns>
        private byte[] HashMessage(SupportedHashAlgorithm hashAlgorithm)
        {
            HashAlgorithm hasher = null;

            switch (hashAlgorithm)
            {
            case SupportedHashAlgorithm.SHA1:
                hasher = new SHA1Managed();
                break;

            case SupportedHashAlgorithm.SHA256:
                hasher = new SHA256Managed();
                break;

            case SupportedHashAlgorithm.SHA384:
                hasher = new SHA384Managed();
                break;

            case SupportedHashAlgorithm.SHA512:
                hasher = new SHA512Managed();
                break;
            }

            var endoding = new UnicodeEncoding();

            var id        = BitConverter.GetBytes(Sequence);
            var createdAt = BitConverter.GetBytes(CreatedAt.ToBinary());
            var strData   = endoding.GetBytes($"{Stream}{Action}{UserDetails}{DataPayload}");

            return(hasher.ComputeHash(id.Concat(createdAt).Concat(strData).ToArray()));
        }
Beispiel #2
0
 public EventMessage(CoreTweet.Streaming.EventMessage cEventMessage)
 {
     CreatedAt    = cEventMessage.CreatedAt.DateTime;
     Id           = CreatedAt.ToBinary();
     Source       = new User(cEventMessage.Source);
     Target       = new User(cEventMessage.Target);
     TargetStatus = cEventMessage.TargetStatus != null ? new Status(cEventMessage.TargetStatus) : null;
     Type         = cEventMessage.Event.ToString();
 }
Beispiel #3
0
        public EventMessage(Status cStatus)
        {
            if (!cStatus.HasRetweetInformation)
            {
                return;
            }

            CreatedAt    = cStatus.CreatedAt;
            Id           = CreatedAt.ToBinary();
            Source       = cStatus.RetweetInformation.User;
            Target       = cStatus.User;
            TargetStatus = cStatus;
            Type         = "Retweet";
        }