Skip to content

Commit

Permalink
256 bit rsa
Browse files Browse the repository at this point in the history
  • Loading branch information
SirGankalot committed Jun 16, 2024
1 parent 57805b6 commit f272787
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions service/src/rsa_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test(p,q):
if p % _ == 0 or q % _ == 0: return False
return True
while True:
p = nBitRandom(128)
p = nBitRandom(256)
p |= 1
q = p + 6
if test(p,q):
Expand All @@ -68,8 +68,8 @@ def get_keys():

async def encryption_of_message(message, public_key):
#make 52 byte/char long messages and add them together to make bigger
byte_len = 20
#byte_len = 52
#byte_len = 20
byte_len = 52
public_key = rsa.PublicKey.load_pkcs1(public_key.encode())
message = message.encode('utf-8')
message_chunks = [message[i:i+byte_len] for i in range(0, len(message), byte_len)]
Expand All @@ -80,8 +80,8 @@ async def encryption_of_message(message, public_key):
return base64.b64encode(cipher_string).decode()

def decryption_of_message(cipher_string, private_key):
byte_len = 32 #64
#byte_len = 64
#byte_len = 32 #64
byte_len = 64
private_key = rsa.PrivateKey.load_pkcs1(private_key.encode())
cipher_string = base64.b64decode(cipher_string)
cipher_array = [cipher_string[i:i+byte_len] for i in range(0, len(cipher_string), byte_len)]
Expand Down

0 comments on commit f272787

Please sign in to comment.