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 DataTransformTests(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 Utf8JsonProvider();

            _originalSize = serializationProvider.Serialize(MyClass).Length;

            _middleware = new DataTransformer(
                serializationProvider,
                new AesGcmEncryptionProvider(hashKey),
                new GzipProvider());

            _serializedData = _middleware
                              .SerializeAsync(MyClass)
                              .GetAwaiter()
                              .GetResult()
                              .ToArray();
        }
Пример #3
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));
        }
        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
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().SetMinimumLevel(LogLevel.Information));

            var metricsProvider = new PrometheusMetricsProvider();

            var serializationProvider = new Utf8JsonProvider();
            var hashingProvider       = new Argon2ID_HashingProvider();
            var hashKey = hashingProvider
                          .GetHashKeyAsync("passwordforencryption", "saltforencryption", 32)
                          .GetAwaiter()
                          .GetResult();

            var encryptionProvider  = new AesGcmEncryptionProvider(hashKey);
            var compressionProvider = new LZ4PickleProvider();

            var rabbitService = new RabbitService(
                "Config.json",
                serializationProvider,
                encryptionProvider,
                compressionProvider,
                loggerFactory);

            services.AddSingleton(
                s =>
            {
                return(new ConsumerDataflowService(
                           s.GetRequiredService <IConfiguration>(),
                           loggerFactory,
                           rabbitService,
                           serializationProvider,
                           compressionProvider,
                           encryptionProvider,
                           metricsProvider));
            });
        }
Пример #6
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();
        }
        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 DataTransformer(
                new Utf8JsonProvider(),
                new AesGcmEncryptionProvider(hashKey),
                new GzipProvider());

            _serializedData = _middleware
                              .SerializeAsync(MyClass)
                              .GetAwaiter()
                              .GetResult()
                              .ToArray();
        }