I know there are plenty of Caesar Cypher reviews on here, but I especially wanted to see how other programmers felt about my use of the cmd module and the efficiency of my functions.
Though this program in its current state is fully functional, I feel the design may be gridlocked and lacking flexibility, due to my lack of knowledge regarding the process of creating commands for the user to utilize.
The current design makes it difficult to implement the varying command attributes I hoped to add later on. How should I go about doing this? A format I see in other cmd programs goes something like
command --numbers --property=number --filename
Thanks for any help and tips in advance.
import cmd def sym_extract(text,syms): text = text[text.find(syms)+1:text.find(syms)] return text def del_punc(string): string = ''.join(ch if ch.isalnum() else '' if ch!=' ' else ' ' for ch in string) return(string.lower()) def cypher(text, shift): text = del_punc(text) secret = '' for c in text: if c in 'abcdefghijklmnopqrstuvwxyz': num = ord(c) num += shift if num > ord('z'): num -= 26 elif num < ord('a'): num += 26 secret = secret + chr(num) else: secret = secret + c return secret class CryptoPromptCmd(cmd.Cmd): prompt = '\n> ' def default(self, arg): print('invalid command, try typing "help"') def do_quit(self, arg): '''exits the program''' return True def do_encrypt(self, arg): '''usage: encrypt (provided string or /filename)[shift number]''' if arg != '': text = del_punc(sym_extract(arg,'()')) shift = int(sym_extract(arg,'')) encrypted = cypher(text,shift) print('\n ',encrypted.upper()) else: print('invalid command\nusage: encrypt(provided string or /filename)[shift number]') return def do_decrypt(self, arg): '''usage:\noutput to file: decrypt(provided string or /filename)[file]\nattempt manually: decrypt(provided string or /filename)[shift number]''' if arg != '': text = del_punc(sym_extract(arg,'()')) shift = -1*int(sym_extract(arg,'')) decrypted = cypher(text,shift) print('\n ',decrypted.upper()) else: print('invalid command\nusage:') print('output to file: decrypt(provided string or /filename)[output /filename]') print('attempt manually: decrypt(provided string or /filename)[shift number]') return if __name__ == '__main__': print('\n'* 3) print("Ian's Caesar Cypher Tool") print('========================') print() print('type "help" for commands') print() CryptoPromptCmd().cmdloop() print('\nexiting...\n')
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!