@AnthonyLosurdo/

Encryption

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pyperclip 

message ='This is my secret message'

key = 13

mode = 'encrypt'

SYMBOLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 !?.'


translated = ''

for symbol in message:
  if symbol in SYMBOLS:
    symbolIndex = SYMBOLS.find(symbol)

    if mode == 'encrypt':
      translatedIndex = symbolIndex + key 
    elif mode == 'decrypt': 
      translatedIndex = symbolIndex - key

    if translatedIndex >= len(SYMBOLS):
      translatedIndex = translatedIndex - len(SYMBOLS)
    elif translatedIndex < 0:
      translatedIndex = translatedIndex + len(SYMBOLS)

      translated = translated + SYMBOLS[translatedIndex]
  else:

    translated = translated + symbol 

print(translated)
pyperclip.copy(translated)