Welcome to the next session in our Biton hacking class that is programming a program to test your particular
program.
So now here, the transposition program seems to work pretty well at encrypting and decrypting different
messages with various keys.
But how do you know?
They always will?
Now, you cannot be absolutely sure the program always work unless you test the encrypt message and
the decrypt message functions with all sorts of message and keep it amateur values.
But this will take a lot of time because you would have to type a message in an encryption program,
said Thuggy.
Run the encryption program then based ciphertext into the decryption program, said the key, and then
run the decryption program.
You would also need to repeat that process with several different keys and messages, resulting in a
lot of boring work.
Now, instead of this, we can write down another program that can generate a random message and a random
key to test the cipher programs.
Now these programs will encrypt the message using the encrypted message matter and then pass that particular
ciphertext to your decrypt message matter.
And if a plain text written by the decrypt message the same as the original message, then the program
will know that the encryption and the decryption program have voted no.
The process of testing a program automatically using another program is called the Automated Testing.
Now several different messages and key combinations need to be tried, but it takes the computer only
a minute or so to test thousands of combinations.
So if all those test pass, then you can be more certain that your code has locked it.
Now to the cover this particular session, which would be also covering the random go round end function,
the random seed function.
We will also see what are different types of list of references.
We will cover the copied or deep copy functions, random code shuffle function, randomly scrambling
a particular string and system exit function.
OK, so now we would come for writing down a particular code for testing our transposition program.
So here we would go for a new file and we would type.
First thing we required is import random.
Then since then trons position encrypt and
transposition decrypt.
Now we would be defining the main method here.
Inside this, let us use the random dot seed function and here we are giving sailele static value for
you.
Now this is, we have said the random C to a static value that we have set it here, not below this.
We would run a for loop which will go in a range.
And between 20, so we're basically going to run 20 test for this encryption and decryption process,
so this will generate some random messages which will be helpful for us to testing.
And then if you go inside the for loop here, we would create a single message SDR that is equal to
let's give some capital numbers.
So g h i j k l and if you want Rusty, you've W, X, Y and Z.
Now we have given everything into capital.
Then here we say multiply multiplied by random dot.
Decline in function, but we are passing for coma for now, this message that we have created will also
have a random length for that length.
We have defined it over here after this.
In the next line, we would say same message as we will do list in bracket message, as are now.
He'll be able to convert the message Asgeir string to a list which will be basically used to shuffle.
And then after this we would use the random dot shuffle function.
And in this also we would pass the message STF now after we have shuffle this, we will create a message
as hour is equal to blank, then dot join and again, let's give your message Asgeir.
Now this is basically used to convert the list back to string and then don't forget to give up command.
Here we are giving the best hash we put into your 10 percent as colon double code as close this single
code, give your bracket five plus one comma.
The value of message estie are all 50 in square brackets and let's close the round bracket.
Now, after this, we will have to check for all the possible keys for each message.
So for that we would go for 60 are in our range.
We are giving you starting from one and converting it to integer.
The length of your message, Estie, are divided by two.
And after this, let's create your.
So encrypted a that's equal to now.
Here we are going to use the transposition, say, transposition and grip dot.
We will use the encrypted message method and we will pass here.
The key is here and the message is still whatever the value will be written will be stored in this encrypted
Ostia.
Similarly, here, we will use decrypted Ostia.
That's equal to psytrance position.
Use the decrypt, not decrypt message.
And again, helth will use the key here.
But now for decrypting, it will have to pass the value that this encrypted SD card here does so that
the same encrypted text would be again decrypted.
So if the decryption doesn't match the original message, we have to display an error message and we'll
have to quit.
So now after this, we will have to go for another safe.
Checking for the message.
Astarte, if that is not equal to your decrypted SDR, then what are you supposed to do?
We will give your opponent saying, say, mismatch with GISTARO percent s and message SDR wasn't as
Clouzot and put into the values of still comma messages dear after this Nibelungen print.
Another saying the decrypted US Colen close this and printed the value of decrypted STF.
And after this we would say Stop it.
Now, once this is done, the next thing we'll have to do is let's come out of this and move back in
the for loop.
Here and here, we would be printing see the transposition cipher text has passed successfully.
That will be the end of this particular session that we have defined the main method.