Hi, so I want to say,
while p is less than the length of the list
for everything in my list (punctuation and characters)
if the letter or punctuation is in my valid letter string
convert it into ascii using ord()
that equals one turn p = p + 1
else if it not in my valid letter string
append it into a list
and then print it, after the while loop
Then I want to say
for every number in the list
excluding those not in my valid letter string
add to another variable i have (its an integer)
however if the result is greater then 126
then take 94 away from it
and change it into character into the ascii character using chr()
Then i want to put all of this into a string
Any help would be greatly appreciated
Thanks!
Here's what i have to start
text_file = input(str("Enter the file you want to be Encyrpted"))
ciphertext_file = input("Enter the file to write the encrypted message out to: ")
#this will find the text file the user has inputter
apple = open(text_file,"r")
#this puts the text file so it can only be read
apple =(apple.read())
print(apple)
n = 0
number = []
texting = []
#================================8 Character Key =================================================
#while n is less than 8
while n<8:
#it will convert a random number between 33 and 126 into ascii
random_number = chr(random.randint(33, 126))
print(random_number)
#every time n + 1
#one turn out of 8
n = n + 1
#the number is put into ascii
characters = ord(random_number)
#it is put into the number list
number.append(characters)
print(number)
#this rounds each of the eight integers in number and divides by 8 and takes away 3
#==================Offset factor====================
offset_number = round((number[0]+number[1]+number[2]+number[3]+number[4]+number[5]+number[7])/8)-32
#this prints the offset factor
print(offset_number)
#=============================Task 5=====================================================================
newString = []
#this is the only part of ascii allowed
validLetters = "#$%&'()*+,-./:;<=>?@[\]^_`{|}~""#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghiklmnopqrstuvwxyz{|}~"
space = [' ']
new = []
old = []
x = 0
#this splits the text file into singukar characters from 0 to 1
chrsplit = [apple[i:i+1] for i in range(0, len(apple),1)]
#this puts into ascii every character
ascii_conversion = [ord(i) for i in chrsplit]
print(ascii_conversion)
#this replaces each 32 in the list with a space
ascii_conversion= "".join(chr(n) for n in ascii_conversion)
ascii_conversion = textwrap.fill(ascii_conversion, 32)
print(ascii_conversion)
banane = 0
for ch in ascii_conversion:
if ch in validLetters:
tangerine = len(ascii_conversion)
else:
banane= banane + 1
guava = []
p = 0
conversion = []
print(tangerine)
while p<tangerine:
for z in ascii_conversion:
if validLetters in ascii_conversion:
chars = [ascii_conversion[i:i+1] for i in range(0, len(ascii_conversion ),1)]
mylist = [ord(i) for i in chars]
p = p + 1
elif x == ' ':
guava.append(x)
print(mylist)