G+_Tnt Seeker Posted May 14, 2014 Share Posted May 14, 2014 Some 'Simple' Encryption and Decryption Code with custom file names EDIT: Please get V.2 if you got it before i Updated it https://github.com/Seeker-of-cod3/Crypt Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted May 15, 2014 Share Posted May 15, 2014 Any such ridiculously long sequence of if...elif..elif... statements should of course be replaced by a single statement using a list. That's what they're for. Link to comment Share on other sites More sharing options...
G+_Darryl Medley Posted May 15, 2014 Share Posted May 15, 2014 Couldn't string.translate() be used instead of a character-by-character conversion loop? That said, the program is a good exercise of some of the things the show has been covering. Link to comment Share on other sites More sharing options...
G+_L I Posted May 16, 2014 Share Posted May 16, 2014 Here's my take on what an encrypt/decrypt function in your program could look like: http://pastebin.com/V0cbQx0F Also when listing the files and asking for them to pick one, use the number they entered as the index to the Folder_Content List and only have one block of code that opens/reads/closes the file. As part of your validation you could make sure that the number they enter is between 0 and the length of Folder_Content. If you ever see patterns of code repeated like that in if-else blocks, it's time to look at what's common between them and reduce the code using a list, a loop, or a function. Link to comment Share on other sites More sharing options...
Recommended Posts