Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
0cbbc77976 | |||
96e8f753ff | |||
7bfe4c3c89 | |||
d7a8ec02ea | |||
960468ad21 | |||
51d9571a37 |
14
rsa.py
14
rsa.py
@ -25,6 +25,8 @@ P=3
|
||||
Q=4
|
||||
PHI=5
|
||||
ID=6
|
||||
FILE_HEADER = "---------- START OF RSA ENCRYPTED MESSAGE ----------"
|
||||
FILE_FOOTER = "---------- END OF RSA ENCRYPTED MESSAGE ----------"
|
||||
|
||||
def main():
|
||||
print("hesham-rsa version ", VERSION)
|
||||
@ -58,8 +60,10 @@ def main():
|
||||
for word in msg_list:
|
||||
msg_encrypted = msg_encrypted + " " + hex(encrypt(word, key_public))
|
||||
#msg_encrypted = encrypt(msg, key_public)
|
||||
sighned_msg = sign(msg_encrypted, signing_key)
|
||||
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:
|
||||
print("Not enough arguments")
|
||||
print("rsa encrypt <message> <key> <signer>")
|
||||
@ -284,6 +288,14 @@ def exportKey(keyFileName):
|
||||
saveKeyFile(public_key, key[ID]+"-public")
|
||||
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.writelines(FILE_HEADER + "\n")
|
||||
msg_file.writelines(msg + "\n")
|
||||
msg_file.writelines(FILE_FOOTER + "\n")
|
||||
|
||||
|
||||
def crackKey(keyName):
|
||||
print("in crack")
|
||||
key = readKeyFile(keyName)
|
||||
|
Loading…
Reference in New Issue
Block a user