Exemplo n.º 1
0
        private void RegisterCrypo(TinyIoCContainer container)
        {
            var keyGenerator = new PassphraseKeyGenerator("forayer globular arse diminish highball wineskin",
                                                          new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 });
            var hmacProvider = new DefaultHmacProvider(keyGenerator);

            container.Register <IHmacProvider>(hmacProvider);
        }
        public void Should_return_array_the_same_size_as_hash_length()
        {
            var provider   = new DefaultHmacProvider(new RandomKeyGenerator());
            var hashLength = provider.HmacLength;

            var result = provider.GenerateHmac("some data");

            result.Length.ShouldEqual(hashLength);
        }
        public void Should_return_hmac_array()
        {
            var provider = new DefaultHmacProvider(new RandomKeyGenerator());

            var result = provider.GenerateHmac("some data");

            result.ShouldNotBeNull();
            result.Length.ShouldBeGreaterThan(0);
        }
        public CookieBasedSessionsFixture()
        {
            this.fakeEncryptionProvider = A.Fake <IEncryptionProvider>();
            this.fakeHmacProvider       = A.Fake <IHmacProvider>();
            this.cookieStore            = new CookieBasedSessions(this.fakeEncryptionProvider, this.fakeHmacProvider, new Fakes.FakeObjectSerializer());

            this.rijndaelEncryptionProvider = new RijndaelEncryptionProvider(new PassphraseKeyGenerator("password", new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }, 1000));
            this.defaultHmacProvider        = new DefaultHmacProvider(new PassphraseKeyGenerator("anotherpassword", new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }, 1000));
        }