April 13, 2019

# The Plan

### What is a Baconian Cipher?

Baconian Cipher is a version of a substitution cipher. Each letter of the alphabet is represented by a pattern where we can use binary digits. For example, the message “a” would be “aaaaa.” In a normal Baconian Cipher, the digits would be represented as “a” or “b” which is what I did. To encode, you would need to know the word you want to encode. For example, I chose the words, YOU. Y would be represented as babba, O would be represented as abbab, and U would be represented as baabb. Forming a code babbaabbabbaabb. Now I would make a phrase that matches the number of digits. The example has 15 digits of the number so I would have to make a phrase with 15 letters not counting the space in-between. For the letter “b” I would need to put a capital letter and for the letter “a” I would need to use lowercase. I wILl cALl YOu nOW would work for this code. So, when using this Cipher, to decode the message, you would need to change the message to binary digits and then match up with the words and numerals.

### What is my plan?

To encode with my Baconian cipher, I am going to use the unicode, and whenever the unicode reads a capital letter, I am going to make that as “b” and “a” for the lowercase letters.

To decrypt my code, I would have to find a way to change all the encoded letters to each alphabet by using the list. I think that if each code of the word is typed in the decrypting code, from the list, the program will check to see if there are any matching of the lists and when there is a match, the corresponding number of the alphabet would appear.

### What are some variables that are needed?

To start off, I would need to have a unicode and figure out what is the range for uppercase letters and lowercase letters. I would also require the for loop to scan each letter of my alphabet to both encode/decode my given code. I would also need to have the if-else block to show the range of my unicode for both upper and lowercase letters. I would also require the list to show my list of codes to encode and decode. For encoding, I would need to replace the list with “a” and “b.”

### What is the final goal?

To make a block of code that can encode a phrase to letters “a” and “b” and decode those letter for secretly sending messages.

_____________________________________________________________________________________________________

# The Product

## Picture:

Explanation:

This is a block of code for my encrypter. To start off, I made a list called “list of numbers.” At first, I thought it would be hard for me to make the letters into b and a, so I thought of changing them into “0” and “1”. However, I found out that there was a block where I can replace an item, so I decided to use a replace item code. Therefore, the items in the list of numbers were not needed because they are replaced by either “a” or “b”. After that, I ask for the phrase that needs to be encrypted.

I made a variable “hi” which is later on set as an encrypted message. The main purpose of variable “hi” is to make the string which is shown after I joined my “hi” and “item(letter i of answer of list of number))).

After that, I use the for loop which shows “i” for index and goes from 1 to the length of the answer. By doing this, the program will read each letter of the response and encrypt each letter according to the corresponding lettersÂ which are “a” or “b.”

The unicode of uppercase letters are A as 65 and Z as 89. By using the if-else loop, the program knows that if the letter is between those ranges, it will encode as “b” if not it will go to the next part of the code. If it is not, it will go to the next which are the lowercases. If it is in the range of the lowercases, it will return “a” if not it wouldn’t return anything. After that, I told the program to join “hi” and the item I replaced to make the encoded code.

Difficulties:

Making this code, I had some challenges figuring out the join block and the replacement block. At first, I had to think logically where would each letter go if I replace. I figured out since the place where each letter of the answer is should be the same for the encrypted code. Therefore, I decided to put replace “letter i of the answer” to arrange the encoded letters in the right spot.

Example:

From the example, I used I wILl cALl YOu nOW, therefore. As a result, the code would read I like “b” and so on. Which would result babbaabbabbaabb, the result came out from the example. The list of numbers and alphabet are on the left side so we can see that there are alphabets where we can type according to the alphabets given. One thing I found out during the reflection is that in the alphabets, I did not mention the uppercase letters are allowed in the code you want to encrypt. Also, I found out that as I was changing the digits back into the letters, I didn’t change the list of numbers.

Decryption

My final product for decryption after reflecting from the last “draft code.” I finally came up with the final product.

Explanation: This is a block of code for my decryption. Unlike the encryption process, I had to change my answer as another scripted variable “original.” This was intended because later on, I had to take out the first letter of my answer. After that, I put the list of encryption and made the alphabet list as I wrote in my plan.

Instead of writing out all of the letters of the alphabet, I decided to make use of the “for” loop. Since the unicode of letter “a” is 97 and “z” is 122, I decided to have an empty list and then add the unicode of the letter for each alphabet.

After that, this is where I have made improvements after thinking about the problem. I figured out that we need a while loop. So, while the length of our answer is equal to zero, the string of “code” is set as 0 to start. Next, we need to repeat 5 times because the encrypted texts are all 5 characters. Now, the letters need to be joined to String for “code.”

This string is needed because late on for the result if we see that the code is equal to any item of encryption, we will be able to return this item as our result. The result variable is scripted to make the String and later on alert the result.

Difficulties:

My decryption code was going off the plan many times. After making the list of codes, I was thinking of how I should make the corresponding item of both lists to come out. Therefore, the encryption took a lot of time. I got my list and set the alphabet from a to z, however because of the I have some difficulties of finding the list. I was not able to finish it yet. For now, I have the variable “space” set as the item letter of I of answer which made it read the length of alphabet getting the 5th alphabet which is “e.” Therefore, I asked for some help.

However, even though I asked for help, some problems came up. For example, we didn’t know how we should use the loops to make sure that the same item # of each list would come out as an answer. I definitely knew how to make the string and the problem of how we are going to use our answer to get the corresponding items. We figured out that we were able to get the first letter of the original and use that as a code to see whether it would fit an item of the “alphabet.” This way, we came up with the solution of how to decode this encrypted message.

Entry Filed under: 2018-2019,Electives,Grade 9. Posted in  2018-2019 ,Electives ,Grade 9 .