|
10 | 10 | char_unicode_old = ord(char) |
11 | 11 |
|
12 | 12 | # checks if it is an uppercase letter or a lowercase letter or a number |
13 | | - upper = char_unicode_old >= 65 and char_unicode_old <= 90 |
14 | | - lower = char_unicode_old >= 95 and char_unicode_old <= 122 |
15 | | - number = char_unicode_old >= 48 and char_unicode_old <= 57 |
| 13 | + upper = char_unicode_old >= 65 and char_unicode_old <= 90 |
| 14 | + lower = char_unicode_old >= 95 and char_unicode_old <= 122 |
| 15 | + number = char_unicode_old >= 48 and char_unicode_old <= 57 |
16 | 16 |
|
17 | 17 | # does nothing if it the character is not a letter or number |
18 | 18 | char_unicode_new = char_unicode_old + (encryption_key * (upper or lower or number)) |
19 | 19 |
|
20 | 20 | # makes unicode only be in between 65 - 90 (A - Z) if the original character was an uppercase letter |
21 | 21 | char_unicode_new += upper * ((91 - ((65 - char_unicode_new) % 26) - char_unicode_new) * (char_unicode_new < 65)) |
22 | | - char_unicode_new += upper * (65 + ((char_unicode_new - 65) % 26) - char_unicode_new) * (char_unicode_new > 90) |
| 22 | + char_unicode_new += upper * ( 65 + ((char_unicode_new - 65) % 26) - char_unicode_new) * (char_unicode_new > 90 ) |
23 | 23 |
|
24 | 24 | # makes unicode only be in between 97 - 122 (a - z) if the original character was a lowercase letter |
25 | | - char_unicode_new += lower * (123 - ((97 - char_unicode_new) % 26) - char_unicode_new) * (char_unicode_new < 97) |
26 | | - char_unicode_new += lower * (97 + ((char_unicode_new - 97) % 26) - char_unicode_new) * (char_unicode_new > 122) |
| 25 | + char_unicode_new += lower * (123 - ((97 - char_unicode_new) % 26) - char_unicode_new) * (char_unicode_new < 97 ) |
| 26 | + char_unicode_new += lower * (97 + ((char_unicode_new - 97) % 26) - char_unicode_new) * (char_unicode_new > 122) |
27 | 27 |
|
28 | 28 | # makes unicode only be in between 48 - 57 (0 - 9) if the original character was a number |
29 | | - char_unicode_new += number * (58 - ((48 - char_unicode_new) % 10) - char_unicode_new) * (char_unicode_new < 48) |
30 | | - char_unicode_new += number * (48 + ((char_unicode_new - 48) % 10) - char_unicode_new) * (char_unicode_new > 57) |
| 29 | + char_unicode_new += number * (58 - ((48 - char_unicode_new) % 10) - char_unicode_new) * (char_unicode_new < 48 ) |
| 30 | + char_unicode_new += number * (48 + ((char_unicode_new - 48) % 10) - char_unicode_new) * (char_unicode_new > 57 ) |
31 | 31 |
|
32 | 32 | message_encrypted += chr(char_unicode_new) |
33 | 33 |
|
34 | 34 | print("Encrypted message : " + message_encrypted) |
35 | 35 |
|
36 | 36 | user_input = input("\tPress enter to continue encrypting messages. Enter 'quit' to exit the program\n>>> ") |
| 37 | + |
0 commit comments