![]() |
F.10 Random Byte Generator for Cryptographic Use |
This tutorial introduces rndbytes$()
, a built-in SheerPower
function that returns a string of cryptographically secure random binary bytes.
It's especially useful for cryptographic applications like
One-Time Pad (OTP) encryption.
A string containing exactly length
cryptographically random binary bytes.
In this example, we’ll use rndbytes$()
to create a one-time pad key
for encrypting a message. The encrypted result is then Base64-encoded
to make it email-safe.
This encrypts the phrase by XORing it with a random byte string of the same length —
a method known as One-Time Pad (OTP) encryption.
The result is then encoded in Base64 so it can be safely included in emails
or transmitted over text-based channels.
To decrypt, simply decode the base64 and then apply xor$()
again using the same key.
Step | Value |
---|---|
Original Phrase | "meet me in the Philippines" |
rndbytes$(len(phrase$)) | e.g., binary: \xA1\x03\xFF\x2C... |
xor$(phrase$, otp_key$) | Encrypted binary string |
base64encode$(...) | "oQI/LC..." (email-safe output) |
Hide Description
|
|
Enter or modify the code below, and then click on RUN |
Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use. |