##### Errors in my encryption algorithm
 Errors in my encryption algorithm SlimeBOOS Unladen Swallow Posts: 3 Threads: 2 Joined: Dec 2017 Reputation: 0 Dec-16-2017, 05:18 PM So.. I wanted to make an algorithm that would encrypt the name of a file. AND I DID IT... i think , because sometimes when i run the algorithm to decrypt a file name it messes up a couple of letters and i don't know why. So could you help me? BTW: i don't encrypt the "." Example of encryption: fileName="FileName.txt" key="123" Output: newFileName="fsxkUjBt.x26" Example of decryption: fileName="fsxkUjBt.x26" key="123" Output: newFileName="LileNate.txt" CODE ```import random fileName="FileName.txt" key="123" mode='c' #c - encrypt #d - decrypt #calculate the seed keySum=sum(ord(i) for i in key) #set the seed random.seed(keySum) newFileName='' newChr='' for i in fileName: #if the current charecter to cipher is a dot skip it if i == '.': newFileName+='.' continue #get the new charecter if mode == 'c': newChr=chr(ord(i)+random.randint(0,26)) elif mode == 'd': newChr=chr(ord(i)-random.randint(0,26)) #make the charecter valid if invalid while True: if ord(newChr) < 48: newChr=chr(ord(newChr)+75) i='{' continue elif ord(newChr) > 57 and ord(newChr) < 65: if ord(newChr) > ord(i): newChr=chr(ord(newChr)+7) continue else: newChr=chr(ord(newChr)-7) continue elif ord(newChr) > 90 and ord(newChr) < 97: if ord(newChr) > ord(i): newChr=chr(ord(newChr)+6) continue else: newChr=chr(ord(newChr)-6) continue elif ord(newChr) > 122: newChr=chr(ord(newChr)-75) i='/' continue break #add the new valid charecter newFileName+=newChr``` Reply SlimeBOOS Unladen Swallow Posts: 3 Threads: 2 Joined: Dec 2017 Reputation: 0 Dec-16-2017, 06:23 PM Solved Reply

 Possibly Related Threads… Thread Author Replies Views Last Post need help one time pad encryption implementation ! nad556 1 262 Nov-28-2020, 06:11 PM Last Post: nad556 encryption and decryption with python ibrahim 1 407 May-16-2020, 03:14 PM Last Post: Larz60+ File encryption itzik 5 573 Nov-05-2019, 12:29 PM Last Post: Gribouillis Vernam encryption method for files JohnCTX 1 573 Sep-18-2019, 04:31 PM Last Post: JohnCTX Regarding encryption and decryption naressh1994 1 769 Jan-25-2019, 07:26 AM Last Post: buran AES encryption - does not match between arduino and python 3 crypto guillaume55 0 2,014 Sep-23-2018, 11:14 AM Last Post: guillaume55 Python function that uses a word as the encryption key, rather than an integer wak_stephanie 4 1,899 Aug-31-2018, 12:16 PM Last Post: perfringo lab experiment / encryption pythan 0 1,071 Jun-09-2018, 07:19 PM Last Post: pythan Attempting to port XTea Encryption from C to Python sonic1015 1 1,740 Jun-06-2017, 07:12 PM Last Post: sonic1015 Testing homemade encryption program in python LEJONKINGEN 1 1,824 Mar-04-2017, 04:09 AM Last Post: wavic

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020