Block overwrite

This commit is contained in:
HeshamTB 2020-09-06 08:07:15 +03:00
parent f5eef6a226
commit 825d8eb647
Signed by: Hesham
GPG Key ID: 74876157D199B09E

10
rsa.py
View File

@ -30,7 +30,12 @@ def main():
print("hesham-rsa version ", VERSION) print("hesham-rsa version ", VERSION)
if sys.argv[1] == "gen" and len(sys.argv) == 4: ##rsa gen <keysize> <keyname> if sys.argv[1] == "gen" and len(sys.argv) == 4: ##rsa gen <keysize> <keyname>
keyFileName = sys.argv[3] keyFileName = sys.argv[3]
key = generateKeys(keyFileName, int(sys.argv[2])) if keyExist(keyFileName):
##ask
print("key already exists")
sys.exit(0)
else:
key = generateKeys(keyFileName, int(sys.argv[2]))
print("e: ", key[E]) print("e: ", key[E])
print("n: ", key[N]) print("n: ", key[N])
print("d: ", key[D]) print("d: ", key[D])
@ -351,5 +356,8 @@ def backTrack(x):
print("\b",end="") print("\b",end="")
length -= 1 length -= 1
def keyExist(keyName):
exist = os.path.exists(keysFolder+keyName)
return exist
if __name__ == "__main__": if __name__ == "__main__":
main() main()