$randomBytes = OC_Util::generateRandomBytes(16); echo bin2hex($randomBytes); // output: e5a467ae09d8f51f889b7156f73d2cbe
$encryptionKey = OC_Util::generateRandomBytes(32); $encryptedData = openssl_encrypt($plainData, 'AES-256-CBC', $encryptionKey);The generateRandomBytes function is part of the ownCloud core library, which is included in the ownCloud server installation.