WIP: read/write text files #2

Closed
Hesham wants to merge 6 commits from file-sys into master
Showing only changes of commit 51d9571a37 - Show all commits

9
rsa.py
View File

@ -57,8 +57,10 @@ def main():
for word in msg_list: for word in msg_list:
msg_encrypted = msg_encrypted + " " + hex(encrypt(word, key_public)) msg_encrypted = msg_encrypted + " " + hex(encrypt(word, key_public))
#msg_encrypted = encrypt(msg, key_public) #msg_encrypted = encrypt(msg, key_public)
sighned_msg = sign(msg_encrypted, signing_key)
print("Encrypted msg: \n", msg_encrypted) print("Encrypted msg: \n", msg_encrypted)
print("Signed: \n", sign(msg_encrypted, signing_key)) ## Adds an encrypted sig at the end of message. print("Signed: \n", sighned_msg) ## Adds an encrypted sig at the end of message.
saveToFile(sighned_msg, "encrypted-msg.txt")
else: else:
print("Not enough arguments") print("Not enough arguments")
print("rsa encrypt <message> <key> <signer>") print("rsa encrypt <message> <key> <signer>")
@ -278,6 +280,11 @@ def exportKey(keyFileName):
saveKeyFile(public_key, key[ID]+"-public") saveKeyFile(public_key, key[ID]+"-public")
print("Saved public form of key {} in keys folder".format(key[ID])) print("Saved public form of key {} in keys folder".format(key[ID]))
def saveToFile(msg, file):
msg = str(msg)
with open(file,"w") as msg_file:
msg_file.write(msg)
def crackKey(keyName): def crackKey(keyName):
print("in crack") print("in crack")
key = readKeyFile(keyName) key = readKeyFile(keyName)