Thursday 27 April 2017

Cryptography - Inspiration from Odu Ifa (Ọ̀pẹ̀lẹ̀ Chain)

The cornerstone of all modern encryption systems is the generation of random numbers. If you want to encrypt any data, you must use cryptographic keys and a key is nothing but a random number that can encrypt or decrypt your data.
A strong key is a key that is very difficult to predict due to the random nature of the number chosen out of endless number series.
Believe it or not, the Ọ̀pẹ̀lẹ̀ chain (see graphic) is a random number generator. Out of the box, this ingenious device can generate 256 random Odus! These 256 Odus can be combined multiple times ad infinitum to generate pseudorandom numbers.
Ọ̀pẹ̀lẹ̀ is a simple but practical device that embodies Number Theory and Probability Theory.
Each toss of the Ọ̀pẹ̀lẹ̀ chain produces a random binary code. Mapping these binary codes to decimal and hexadecimal numbers will be explained in the next post.
Below is a quick and dirty computer code (in Javascript) that simulates the tossing of the Ọ̀pẹ̀lẹ̀ chain to generate random binary codes. You can run it in your browser by saving it on your computer (e.g as opele.html). Each time the browser is refreshed (by pressing F5 or the refresh button), a new random code is displayed.
<html>
<head>
<script language="javascript">
var odu = ["|", "||"];
for (i=0; i<4; i++) {
    var odu1 = odu[Math.floor(Math.random() * odu.length)];
    var odu2 = odu[Math.floor(Math.random() * odu.length)];
    document.write("<b>" + odu1 + "&nbsp&nbsp&nbsp&nbsp" + odu2 + "</b>" + "<br>");
}
</script>
</head>
</html>
A similar logic with the Python programming language is as follows...
import random
odu = ['|', '||']
def difa():
for x in range(4)
    print "%2s %2s" %(random.choice(odu), random.choice(odu))
if __name__ == '__main__':
    difa()


No comments:

Post a Comment