blob: 2a3c93d5b9dc4a94a983c4f4d1d57150df01238f [file] [log] [blame]
# various RNGs Python example
import oqs.rand as oqsrand # must be explicitly imported
#######################################################################
# randomness example
#######################################################################
# set the entropy seed to some random values
entropy_seed = [0] * 48
entropy_seed[0] = 100
entropy_seed[20] = 200
entropy_seed[47] = 150
oqsrand.randombytes_nist_kat_init(bytes(entropy_seed))
oqsrand.randombytes_switch_algorithm('NIST-KAT')
print('{:17s}'.format("NIST-KAT:"), ' '.join('{:02X}'.format(x) for x in oqsrand.randombytes(32)))
oqsrand.randombytes_switch_algorithm("OpenSSL")
print('{:17s}'.format("OpenSSL:"), ' '.join('{:02X}'.format(x) for x in oqsrand.randombytes(32)))
oqsrand.randombytes_switch_algorithm("system")
print('{:17s}'.format("System (default):"), ' '.join('{:02X}'.format(x) for x in oqsrand.randombytes(32)))