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 })); }
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)); }
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 })); }
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); }