blob: aa5250969d1f52a962e73ca796647e44f1375731 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import rsautils as ru
n = int(input('n: '))
e = int(input('e (make sure it\'s relatively prime to p-1 and q-1): '))
message = input('message:\n')
messagenum = 0
messagenum = ru.string2int(message)
messageblocks = ru.int2list(messagenum,n,endian="big")
def encrypt_block(blk):
return (blk ** e) % n
encrypted = [encrypt_block(block) for block in messageblocks]
print(ru.int2base64(ru.list2int(encrypted,n)))
|