In this script a random number is generated, before the number is passed the number is checked if it is a prime number if it is then the number is passed. I can either do this with calling a function that checks for prime number validity or use a decorator. A decorator is a function … Continue reading [python]Check if randomly generated number is a prime with decorator
There are two functions in python which can convert the ascii to the integer equivalent and vice versa. To convert ascii character to integer representation use ord(), to convert integer to ascii representation use chr(). Example: Result [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33] hello world!
I wrote this script to teach myself on how to do RSA key generation (public key e and private key d), and how to encrypt and decrypt message mathematically. This tool will also be used as a refresher if I have forgotten how to calculate the RSA mathematics. This learning tool presents how the Euclidean … Continue reading [python]RSA mathematics learning tool
I took my exam last night, and I guessed I would fail as I did not know how to calculate extended Euclidean Algorithm required for RSA. I came across this video, which explained eGCD really well, better than the slides I had and the tutor's explanation, the substitution method explained by my tutor was confusing. … Continue reading [python]Extended Euclidean Algorithm
I am studying how to calculate RSA, and in the way the formula has something related to GCD, not only in RSA also in Affine Cipher also has a condition that gcd(a, b) = 1 when choosing a and b as keys. So this is a code snippet after I have learned about gcd. The … Continue reading [python] Greatest Common Denominator
I am studying for examination, and i could not actually find the solution by hand while doing decryption, basically i felt inverse modulus is very hard to understand (using the Euclidean algorithm). I am still trying and practising by hand and I have decided to write a python script to help me verify my decryption … Continue reading [python]Affine cipher
Ok, I was studying my examination and I was directed to watch this video to understand how Diffie Hellman (DH) key exchange works mathematically, the video was really good, concise and easy to understand, so to add spice to my study (study for examination is the world's most boring thing to do) I wrote a … Continue reading [python] Diffie Hellman key exchange demo…