I'm currently writing a reasonably basic encryption algorithm for my CS Coursework, where the encryption is based on pre-defined shuffles which are based on a 64 character ASCII clone I made (0-9, lowercase alphabet, uppercase alphabet, apostrophe and space).
The encryption key is based on two random HEX values, the first is to determine which of the 16 excel documents with 16 possible shuffles each, of which is defined by the second HEX value. The HEX values are randomised. This is repeated 3 times to create a 6 character key made of those HEX values. e.g. if the first two characters of the key were A3, it would be the 10th excel spreadsheet out of 16, and the third set of scrambles in that document.
Now would be a good time to note that this isn't supposed to be secure, but rather a way to visualise how a basic algorithm would work, and I know it doesn't follow Kerchoff's principle. Now for the actual part I'm stuck with.
import pandas as pd
import random
TSCIS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
key1 = random.choice(TSCIS)
key2 = random.choice(TSCIS)
excel_file = pd.read_excel(r'C:\###\spreadsheetE.xls')
For where the "spreadsheetE" in the destination of where the 16 spreadsheets are, would it be possible to replace the "E" at the end of it with the value of key2? e.g. spreadsheetA so that the file opened is dependent on the value?
Note: TSCIS is the name I've given to the 64 char ASCII replacement.
Note that this is just a draft of a module of the project.
CodePudding user response:
As Jon mentions, you could do string formatting. Example:
filename='spreadsheet' key2 '.xls'
excel_file =pd.read_excel(r'C:###\{}'.format(filename))