randommariadb

RANDOM_BYTES or CRYPT_GEN_RANDOM equivalent in MariaDB


Question

Are any alternatives of MySQL RANDOM_BYTES(len) or MSSQL CRYPT_GEN_RANDOM(len) available in MariaDB?

I read through their documentation, but I only found rand(len), which is not cryptographically secure in generating random bytes.

Issues

Currently released version of MariaDB (10.3) does not support RANDOM_BYTES(len) according to this documentation https://mariadb.com/kb/en/library/function-differences-between-mariadb-103-and-mysql-57/

Limitation

If possible, keep the code within the MariaDB, and I don't want to rely on PHP or any other external functions for security reasons.


Solution

  • It seems RANDOM_BYTES(length) is available since 10.10.0 (preview release) Check the documentation.