コード例 #1
0
ファイル: UnitTests.cs プロジェクト: 4ezy/MailClient
        public void SignCheck()
        {
            string   data     = "123";
            Encoding encoding = Encoding.GetEncoding(Encoding.UTF8.CodePage);

            byte[] encrData = Encrypter.EncryptWithAesAndRsa(encoding.GetBytes(data),
                                                             "vasya");
            byte[] signedData = Encrypter.SignData(encrData,
                                                   "vasya");
            string encString = String.Empty;

            for (int i = 0; i < signedData.Length; i += 2)
            {
                encString += BitConverter.ToChar(signedData, i);
            }

            char[]      rtfText = encString.ToCharArray();
            List <byte> dat     = new List <byte>();

            for (int i = 0; i < rtfText.Length; i++)
            {
                byte[] charBytes = BitConverter.GetBytes(rtfText[i]);
                dat.AddRange(charBytes);
            }

            bool actual = Encrypter.CheckSign(dat.ToArray(),
                                              "vasya");
            bool expected = true;

            Assert.AreEqual(expected, actual);
        }