## On the Subject of The Forest Cipher

Trees, shrubs, wildlife and ... rotations?

On the module, you will see 3 screens, a keyboard, 2 arrows, and a submit button that displays the current page you’re on.

Pressing the right arrow takes you to the next page. Pressing the left arrow takes you to the previous page. There is a total of 2 pages.

### Step 1: Chain Bit-Rotation Cipher

For this step, you will need everything on page 1, which we will call the encrypted word, the initial number, and the keyword, respectively. If the keyword is shorter than 6 letters, append a repetition of it to it.

Start with the initial number, then carry out the following steps for every letter of the encrypted word: (1) multiply the number by 26; (2) add the alphabetic position of the letter. If the letter is Z, add 0 instead.

Convert this number to binary. Now, starting with a value `n` of 30, carry out the following steps 6 times:

- Cycle the least significant
`n`bits to the right by`m`bits. Here,`m`is the alphabetic position of the next letter in the keyword. (Make sure to cycle all`n`bits; if your number has fewer digits, add leading zeros.) - Remove the least significant 5 bits from the number and convert them to a letter (A = 00001 ... Z = 11010).
- Reduce
`n`by 5.

#### Example

Encrypted word: XOGXTU; initial value: 2; keyword: DINE

Calculation: (((((2×26 + 24)×26 + 15)×26 + 7)×26 + 24)×26 + 20)×26 + 21

Binary: 110110001111010010110110000101

Cycle 30 bits right by D=4: 0101110110001111010010110*11000* → 24 → X

Cycle 25 bits right by I=9: 01001011001011101100*01111* → 15 → O

Cycle 20 bits right by N=14: 110010111011000*10010* → 18 → R

Cycle 15 bits right by E=5: 1100011001*01110* → 14 → N

Cycle 10 bits right by D=4: 10011*10001* → 17 → Q

Cycle 5 bits right by I=9: 00111 → 7 → G

New Encrypted Word: XORNQG