internal byte[] Export()
        {
            var bytes = new List <byte>();
            var type  = Encoding.ASCII.GetBytes(GetType().FullName);

            bytes.AddRange(BitConverter.GetBytes((short)type.Length)); // todo: maybe change to maxlen=256 so we can save a byte
            bytes.AddRange(type);

            var state = ExportData;

            if (state == null)
            {
                bytes.Add(0);
            }
            else
            {
                bytes.AddRange(BitConverter.GetBytes(state.Length));
                bytes.AddRange(state);
            }

            var key = GetUnlockedKey();

            bytes.AddRange(BitConverter.GetBytes(key.Length));
            bytes.AddRange(key);

            if (ChainedInnerKey != null)
            {
                bytes.AddRange(ChainedInnerKey.Export());
            }

            var arr = bytes.ToArray();

            bytes.Clear();
            return(arr);
        }
 internal bool IsPeriodicallyAccessibleKey(PropertyInfo property)
 {
     if (ChainedInnerKey != null && ChainedInnerKey.IsPeriodicallyAccessibleKey(property))
     {
         return(true);
     }
     return(IsPeriodicallyAccessibleKey());
 }
        internal byte[] Decrypt(PropertyInfo property, byte[] bytes)
        {
            var unlockedKey  = GetUnlockedKey();
            var unlockedData = Decrypt(property, unlockedKey, bytes);

            var result = ChainedInnerKey != null?ChainedInnerKey.Decrypt(property, unlockedData) : unlockedData;

            Zero(unlockedKey);
            return(result);
        }
        internal byte[] Encrypt(PropertyInfo property, byte[] bytes)
        {
            var innerProcessedData = ChainedInnerKey != null?ChainedInnerKey.Encrypt(property, bytes) : bytes;

            var unlockedKey = GetUnlockedKey();
            var result      = Encrypt(property, unlockedKey, innerProcessedData);

            Zero(unlockedKey);
            return(result);
        }