internal DefaultHttpMessageCryptoServiceWrapper(ITimestampProvider<string> timestampProvider)
        {
            var symmetricAlgorithm = new AES("secretKeyPassword", "initialVectorPassword");
            var hashAlgorithm = new HMACSHA512("hashKeyString");

            this.inner = new DefaultHttpMessageCryptoService(symmetricAlgorithm, hashAlgorithm, timestampProvider);
        }
Ejemplo n.º 2
0
        public ServerCryptoHandler(string secretKeyPassword, string initialVectorPassword, string hashKeyString)
        {
            var symmetricAlgorithm = new AES(secretKeyPassword, initialVectorPassword);
            var hashAlgorithm = new HMACSHA512(hashKeyString);
            var timestampProvider = new DefaultTimestampProvider(TimeSpan.FromMinutes(15)) as ITimestampProvider<string>;

            this.messageCryptoService = new DefaultHttpMessageCryptoService(symmetricAlgorithm, hashAlgorithm, timestampProvider);
        }
Ejemplo n.º 3
0
        public void AESTest_Encrypt()
        {
            using (var target = new AES("123456789012345678901234", "12345678"))
            {
                var plainText = "`1234567890-=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@#$%^&*()_+";

                var plain = Encoding.UTF8.GetBytes(plainText);
                var cipher = target.Encrypt(plain);
                var cipherText = Convert.ToBase64String(cipher);

                Assert.AreEqual(
                    "xRANotL/km4vWpPwPw6P1H8T2UXptwMGyFShVH/BmXsnv6E+pOTtfeOPfsbfap5TD1DfMTdOn94t1j/sk9NU984ESJn1wi2QEDmgR/SI3B4=",
                    cipherText);
            }
        }