SQLite randomblob() Function

The SQLite randomblob() function returns a blob consisting of a given number of pseudorandom bytes.

Syntax

Here is the syntax of the SQLite randomblob() function:

randomblob(n)

Parameters

n

Required. The number of bytes. If n is less than 1, then n will be considered as 1.

Return value

The SQLite randomblob() function returns a blob of n bytes containing pseudorandom bytes.

Examples

To generate a blob containing a random byte, use the following statement:

SELECT hex(randomblob(1));
hex(randomblob(1))
------------------
CC

Here, we use the hex() function to convert the result of randomblob(1) to its hexadecimal representation.

To generate a blob containing 10 random bytes, use the following statement:

SELECT hex(randomblob(10));
hex(randomblob(10))
--------------------
566ED959DC74266F9C81