Exemple #1
0
        public static byte[] EncodeToByteArray(string message, CryptoMessage.EncodingKind encodingKind)
        {
            if (message == null)
            {
                message = string.Empty;
            }
            byte[] array = new byte[]
            {
                (byte)encodingKind
            };
            byte[] bytes;
            switch (encodingKind)
            {
            case CryptoMessage.EncodingKind.UTF8:
                bytes = new UTF8Encoding().GetBytes(message);
                goto IL_43;
            }
            bytes = new UnicodeEncoding().GetBytes(message);
IL_43:
            return(CryptoMessage.MergeArrays(new byte[][]
            {
                array,
                bytes
            }));
        }
Exemple #2
0
 public CryptoMessage(DateTime timeStamp, string message, Guid userContextId, string logonUniqueKey)
 {
     byte[] bytes = BitConverter.GetBytes(timeStamp.Ticks);
     byte[] array = CryptoMessage.EncodeToByteArray(message, CryptoMessage.EncodingKind.UTF8);
     this.CreateSignedMessage(CryptoMessage.MergeArrays(new byte[][]
     {
         bytes,
         array
     }), CryptoMessage.GetHiddenMessage(userContextId, logonUniqueKey));
 }
Exemple #3
0
 public static byte[] GetHiddenMessage(Guid userContextId, string logonUniqueKey)
 {
     byte[] array = userContextId.ToByteArray();
     byte[] bytes = new UnicodeEncoding().GetBytes(logonUniqueKey ?? string.Empty);
     return(CryptoMessage.MergeArrays(new byte[][]
     {
         array,
         bytes
     }));
 }
Exemple #4
0
 private void CreateSignedMessage(byte[] message, byte[] hiddenMessage)
 {
     this.messageBinary       = CryptoMessage.Clone(message);
     this.hiddenMessageBinary = CryptoMessage.Clone(hiddenMessage);
     this.privateKeyBinary    = CryptoMessage.MergeArrays(new byte[][]
     {
         CryptoMessage.adObjectIdsBinary,
         this.hiddenMessageBinary
     });
     this.hashBinary           = CryptoMessage.ComputeHash(this.messageBinary, this.privateKeyBinary);
     this.hashAndMessageBinary = CryptoMessage.MergeArrays(new byte[][]
     {
         this.hashBinary,
         this.messageBinary
     });
     this.hashAndMessageString = CryptoMessage.Encode(this.hashAndMessageBinary);
 }