Esempio n. 1
0
        //
        static internal byte[] DatabaseObjectShellToByteArray(DataBaseObjectShell _obj)
        {
            if (_obj == null)
            {
                return(null);
            }
            BinaryFormatter bf = new BinaryFormatter();

            using (MemoryStream ms = new MemoryStream())
            {
                bf.Serialize(ms, _obj);
                return(ms.ToArray());
            }
        }
        static internal byte[] DecryptDatabaseObjectShellArrayToDatabaseBytes(byte[] dbShellbytes)
        {
            DataBaseObjectShell shellObject = ByteArrayToDatabaseObjectShell(dbShellbytes);

            byte[] _dbInstance;
            byte[] password = SharedCryptingMethods.GetKeyBytes(SharedCryptingMethods.SecretCryptKeyFormula(shellObject.CryptKey));
            using (var myAes = Aes.Create())
            {
                myAes.Key   = password;
                myAes.IV    = shellObject.IV;
                _dbInstance = AES.decryptStream(shellObject.DataBaseInstanceArray, myAes.Key, myAes.IV);
            }
            return(_dbInstance);
        }