public static byte[] Decrypt(Type objectType, byte[] bytes) { if (SiaqodbConfigurator.EncryptedDatabase) { int lengthOfType = -1; if (objectType == typeof(string) || objectType == typeof(byte[])) { lengthOfType = bytes.Length; } else { lengthOfType = MetaHelper.GetLengthOfType(objectType); } SiaqodbConfigurator.Encryptor.Decrypt(bytes, 0, bytes.Length); if (bytes.Length == lengthOfType) { return(bytes); } else { byte[] realBytes = new byte[lengthOfType]; Array.Copy(bytes, 0, realBytes, 0, lengthOfType);//un-padd the bytes return(realBytes); } } return(bytes); }