public RecyclableTransformTests(ITestOutputHelper output)
        {
            _output = output;
            Enumerable.Repeat <byte>(0xFF, 1000).ToArray().CopyTo(_data, 0);
            Enumerable.Repeat <byte>(0xAA, 1000).ToArray().CopyTo(_data, 1000);
            Enumerable.Repeat <byte>(0x1A, 1000).ToArray().CopyTo(_data, 2000);
            Enumerable.Repeat <byte>(0xAF, 1000).ToArray().CopyTo(_data, 3000);
            Enumerable.Repeat <byte>(0x01, 1000).ToArray().CopyTo(_data, 4000);

            MyClass.ByteData = _data;

            var hashingProvider = new Argon2ID_HashingProvider();
            var hashKey         = hashingProvider.GetHashKey(Passphrase, Salt, 32);

            var serializationProvider = new NewtonsoftJsonProvider();

            _originalSize = serializationProvider.Serialize(MyClass).Length;

            _middleware = new RecyclableTransformer(
                serializationProvider,
                new RecyclableGzipProvider(),
                new RecyclableAesGcmEncryptionProvider(hashKey));

            (_serializedData, _serializedLength) = _middleware.Transform(MyClass);
        }
Пример #2
0
        public void Setup()
        {
            Enumerable.Repeat <byte>(0xFF, 1000).ToArray().CopyTo(_data, 0);
            Enumerable.Repeat <byte>(0xAA, 1000).ToArray().CopyTo(_data, 1000);
            Enumerable.Repeat <byte>(0x1A, 1000).ToArray().CopyTo(_data, 2000);
            Enumerable.Repeat <byte>(0xAF, 1000).ToArray().CopyTo(_data, 3000);
            Enumerable.Repeat <byte>(0x01, 1000).ToArray().CopyTo(_data, 4000);

            MyClass.ByteData = _data;

            var hashingProvider = new Argon2ID_HashingProvider();
            var hashKey         = hashingProvider.GetHashKey(Passphrase, Salt, 32);

            RecyclableManager.ConfigureNewStaticManagerWithDefaults();

            _middleware = new RecyclableTransformer(
                new Utf8JsonProvider(),
                new RecyclableGzipProvider(),
                new RecyclableAesGcmEncryptionProvider(hashKey));
        }
Пример #3
0
        public static void Setup()
        {
            Enumerable.Repeat <byte>(0xFF, 1000).ToArray().CopyTo(_data, 0);
            Enumerable.Repeat <byte>(0xAA, 1000).ToArray().CopyTo(_data, 1000);
            Enumerable.Repeat <byte>(0x1A, 1000).ToArray().CopyTo(_data, 2000);
            Enumerable.Repeat <byte>(0xAF, 1000).ToArray().CopyTo(_data, 3000);
            Enumerable.Repeat <byte>(0x01, 1000).ToArray().CopyTo(_data, 4000);

            MyClass.ByteData = _data;

            var hashingProvider = new Argon2IDHasher();
            var hashKey         = hashingProvider.GetHashKey(Passphrase, Salt, 32);

            _middleware = new RecyclableTransformer(
                new NewtonsoftJsonProvider(),
                new RecyclableAesGcmEncryptionProvider(hashKey, hashingProvider.Type),
                new RecyclableGzipProvider());

            (var buffer, _) = _middleware.Input(MyClass);
            _serializedData = buffer.ToArray();
        }
        public void Setup()
        {
            Enumerable.Repeat <byte>(0xFF, 1000).ToArray().CopyTo(_data, 0);
            Enumerable.Repeat <byte>(0xAA, 1000).ToArray().CopyTo(_data, 1000);
            Enumerable.Repeat <byte>(0x1A, 1000).ToArray().CopyTo(_data, 2000);
            Enumerable.Repeat <byte>(0xAF, 1000).ToArray().CopyTo(_data, 3000);
            Enumerable.Repeat <byte>(0x01, 1000).ToArray().CopyTo(_data, 4000);

            MyClass.ByteData = _data;

            var hashingProvider = new Argon2ID_HashingProvider();
            var hashKey         = hashingProvider.GetHashKey(Passphrase, Salt, 32);

            _middleware = new RecyclableTransformer(
                new Utf8JsonProvider(),
                new RecyclableGzipProvider(),
                new RecyclableAesGcmEncryptionProvider(hashKey));

            (var buffer, var length) = _middleware.Transform(MyClass);
            _serializedData          = buffer.ToArray();
            _serializedLength        = length;
        }
Пример #5
0
        public void Setup()
        {
            Enumerable.Repeat <byte>(0xFF, 2_000).ToArray().CopyTo(_data, 0);
            Enumerable.Repeat <byte>(0xAA, 2_000).ToArray().CopyTo(_data, 2_000);
            Enumerable.Repeat <byte>(0x1A, 2_000).ToArray().CopyTo(_data, 4_000);
            Enumerable.Repeat <byte>(0xAF, 2_000).ToArray().CopyTo(_data, 6_000);
            Enumerable.Repeat <byte>(0x01, 2_000).ToArray().CopyTo(_data, 8_000);

            MyClass.ByteData = Encoding.UTF8.GetString(_data);

            var hashingProvider = new Argon2ID_HashingProvider();
            var hashKey         = hashingProvider.GetHashKey(Passphrase, Salt, 32);

            //RecyclableManager.ConfigureNewStaticManagerWithDefaults();

            _middleware = new RecyclableTransformer(
                new Utf8JsonProvider(),
                new RecyclableGzipProvider(),
                new RecyclableAesGcmEncryptionProvider(hashKey));

            (var buffer, _) = _middleware.Transform(MyClass);
            _serializedData = buffer.ToArray();
        }