Exemple #1
0
        public NanoPost(string raw)
        {
            _raw  = raw;
            _hash = HashCalculator.Calculate(_raw);

            if (raw.Length <= HashCalculator.HashCrop * 2)
            {
                Invalid = true;
                return;
            }

            ReplyTo = new Hash(raw.Substring(0, HashCalculator.HashCrop * 2));
            Message = raw.Substring(HashCalculator.HashCrop * 2);

            _bytes = Encoding.UTF8.GetBytes(_raw);
            if (_bytes.Length > NanoPost.MaxPostByteLength)
            {
                Invalid = true;
            }

            if (ReplyTo.Invalid)
            {
                Invalid = true;
            }
        }
Exemple #2
0
        public NanoPost(Hash replyTo, string message)
        {
            _raw  = replyTo.Value + message;
            _hash = HashCalculator.Calculate(_raw);

            ReplyTo = replyTo;
            Message = message;

            _bytes = Encoding.UTF8.GetBytes(_raw);
            if (_bytes.Length > NanoPost.MaxPostByteLength)
            {
                Invalid = true;
            }

            if (ReplyTo.Invalid)
            {
                Invalid = true;
            }
        }