Python ASCII Encryption Problems

Raw_String=input("What is your string?")
Raw_Stringlen=len(Raw_String)
PassKey=int(input("What is your passkey?"))#You neeeeeeeeeed the int part!!1
PassKeystr=str(PassKey)

for a in Raw_String:
ASCII_String=ord(a)
PassKey_String=(ASCII_String*(PassKey))
print(PassKey_String)
PassKey_Stringstr=str(PassKey_String)
PassKeylen=len(PassKeystr)

Decrypt_Option=input("Would you like to decrypt what you just wrote?")

if Decrypt_Option=="yes":
PassKey_Decrypted_String=int(PassKey_String/PassKey)
PassKey_Decrypted_String_List=[PassKey_Decrypted_String]

If I were to enter the string "jack" into Raw_String, I keep getting "k" back from the print out, however I wont to know how to print out the entire thing.

for h in PassKey_Decrypted_String_List:
    print(chr(h))
1 Like

You don't appear to be using a python encryption library. Unless you want to spend years making and testing your own encryption you should use a library. PyCrypto Library

With that said, it does not seem your putting the PassKey_String into a list? Its pretty difficult to read python code when its not formatted.

pycrypto is obsolete. use python-cryptography.

cryptography is extremely idiot-proof with this one.

EDIT: If you look at PyCrypto, the upload date for 2.6.1 is 2014-06-20. So, 2 years ago. A lot changes in 2 years.

2 Likes

@ThermalSponge

If you are on Linux you need certain packages to build this,

The Debians:

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

The Red Hats:

sudo dnf install gcc libffi-devel python-devel openssl-devel

Then run pip:

pip install cryptography

if you still have trouble with python3 package try:

python3 -m pip install cryptography
1 Like

Thank you so much all. I hate to be an ass but after sleeping on it I managed to find the solution, and wrote it in a much easier way to understand. Thanks for the help.

Here is the code if you happen to be curious:

import time
import os
message=input("What is your message?")
passkey=int(input("What is your PassKey?"))

for a in (message):
ascii_message=(ord(a))
passkey_message=(ascii_message*(passkey))
passkey_message_int=int(passkey_message)
decoded_passkey=int(passkey_message/passkey)
decoded_message=(chr(decoded_passkey))
decoded_message_str=str(decoded_message)
print(decoded_message_str, end="")

time.sleep(3)