(p_val)
| 17 | # so I used 4.80 Algorithm in Handbook of Applied Cryptography(CRC Press, ISBN : 0-8493-8523-7, October 1996) |
| 18 | # and it seems to run nicely! |
| 19 | def primitiveRoot(p_val): |
| 20 | print("Generating primitive root of p") |
| 21 | while True: |
| 22 | g = random.randrange(3,p_val) |
| 23 | if pow(g, 2, p_val) == 1: |
| 24 | continue |
| 25 | if pow(g, p_val, p_val) == 1: |
| 26 | continue |
| 27 | return g |
| 28 | |
| 29 | |
| 30 | def generateKey(keySize): |