예제 #1
0
 public void Transform_12KB(int x)
 {
     for (var i = 0; i < x; i++)
     {
         _middleware.Transform(MyClass);
     }
 }
        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);
        }
        public void Transform()
        {
            (var transformedData, var length) = _middleware.Transform(MyClass);

            Assert.NotNull(transformedData);
            Assert.Equal(_serializedLength, transformedData.ToArray().Length);
        }
예제 #4
0
 public void Serialize_Deserialize_7KB(int x)
 {
     for (var i = 0; i < x; i++)
     {
         (var buffer, var length) = _middleware.Transform(MyClass);
         _middleware.Restore <MyCustomClass>(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;
        }
예제 #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 Serialize_7KB()
 {
     _middleware.Transform(MyClass);
 }