To all my viewers I'm currently a member of the internship program for a human welfare council and I need your help to assist the people who need us by donating any amount you can. YOUR SMALL GESTURE WILL HELP A FAMILY SMILE. Follow the link and you will get to our campaign page :
Please after funding whatever amount you can share me the screenshot of the receipt to my email - sumanmukherjee2001@gmail.com
So that I can send you a receipt for the contribution you made and tell the happiness you shared. 😊
The Caesar Cipher was one of the earliest ciphers ever invented. In this cipher, you encrypt a message by taking each letter in the message (in cryptography, these letters are called symbols because they can be letters, numbers, or any other sign) and replacing it with a “shifted” letter. If you shift the letter A by one space, you get the letter B. If you shift the letter A by two spaces,
you get the letter C.
This more safe Cypher than the Reverse Cypher because it require your key but however it also can be easily cracked because there are only 26 keys available and the computer won't take long to use all 26 keys.It woul take about a hundread of a second to calculate for the computer.
With this source code, you can both encrypt or decrypt a message provided that you know the key.
Source Code :-
---------------------------------------------------------------------------------
MAX_KEY_SIZE = 26 def getMode(): while True: print('Do you wish to encrypt or decrypt a message?') mode = input().lower() if mode in 'encrypt e decrypt d'.split(): return mode else: print('Enter either "encrypt" or "e" or "decrypt" or "d".') def getMessage(): print('Enter your message:') return input() def getKey(): key = 0 while True: print('Enter the key number (1-%s)' % (MAX_KEY_SIZE)) key = int(input()) if (key >= 1 and key <= MAX_KEY_SIZE): return key def getTranslatedMessage(mode, message, key): if mode[0] == 'd': key = -key translated = '' for symbol in message: if symbol.isalpha(): num = ord(symbol) num += key if symbol.isupper(): if num > ord('Z'): num -= 26
elif num < ord('A'): num += 26
elif symbol.islower(): if num > ord('z'): num -= 26
elif num < ord('a'): num += 26 translated += chr(num) else: translated += symbol return translated mode = getMode() message = getMessage() key = getKey() print('Your translated text is:') print(getTranslatedMessage(mode, message, key))
---------------------------------------------------------------------------------
Result:-
Encryption
Decryption
If you face any problem just inform to me in the comments below and don't forget to check my blog daily :)
No comments:
Post a Comment