r/AskAnythingPython • • Sep 08 '23

Which is your favorite code editor?

I started with PyCharm and then I tried out VS Code. It was hard to setup at first but was totally worth it eventually. It loads up fast and has automatically formats the code as you save it. Overall It feels so much smoother and light weight than PyCharm!

I followed this tutorial and I feel like a professional hacker coding up my calculator. If anyone is interested, here's the link to the setup I followed:

https://medium.com/@ordinaryindustries/the-ultimate-vs-code-setup-for-python-538026b34d94

3 Upvotes

21 comments sorted by

View all comments

Show parent comment

1

u/kitkatmafia Sep 08 '23

the real question is, can you beat the ceaser algorithm?

2

u/ShadowRL766 Sep 08 '23
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n")
text = input("Type your message:\n").lower()
shift = int(input("Type the shift number:\n"))

def encrypt(plaintext, shift_amount):
    cipher_text = ""
    for letter in plaintext:
        position = alphabet.index(letter)
        new_position = position + shift_amount
        new_letter = alphabet[new_position]
        cipher_text += new_letter
    print(f"The encoded text is {cipher_text}")



def decrypt(cipher_text, shift_amount):
    decrypted_text = ""
    for letter in cipher_text:
        position = alphabet.index(letter)
        old_position = position - shift_amount
        old_letter = alphabet[old_position]
        decrypted_text += old_letter
    print(f"The decoded text is {decrypted_text}")


if direction == "encode":
    encrypt(plaintext=text, shift_amount=shift)
elif direction == "decode":
    decrypt(cipher_text=text, shift_amount=shift)

1

u/kitkatmafia Sep 08 '23

haha, this looks really good. try breaking this cipher wihtout knowing the shift., for example like you could check all the 26 possible shifts and for every shift see if a word makes sense. like you could compare a word in each shift with large dictionary of common words - that'll be cool

1

u/ShadowRL766 Sep 08 '23

Yeah brute forcing the shift is one way.

1

u/kitkatmafia Sep 08 '23

thats the only one on top of my head. what other ways are there?

2

u/ShadowRL766 Sep 08 '23

Uhm doing it manually 😭

1

u/kitkatmafia Sep 08 '23

jesus, i take back everything i said lol

1

u/ShadowRL766 Sep 08 '23

?

1

u/kitkatmafia Sep 08 '23

you just proved you are a pro software engineer :D

1

u/ShadowRL766 Sep 08 '23

Funny you say that I just created a ceased cipher in python.