Encryption is a technique used to transform a string into another such that the algorithm to reverse the transformation is complex and only decipherable by the original encrypter.

## Simple encryption

### Cesarean Cipher

This encryption technique was allegedly used in the times of the Roman emperor Julius Caesar who made carriers of the message swear never to reveal the key.[1] A simple encryption program can use the following technique to create a Cesarean Cipher.

• First, convert the string into a list of letters
• Then, iterating through each item of the list, use many If () Then blocks to replace each character with a unique other character
• Finally, join these back into a string and report

To decode, do the same thing, except replace backwards: encrypted values to their keys, rather than keys to values.

This can be used to convert a string like: "Hello world" into "Rqbbwx wmbbf" Note how the lengths of words change. This is because the space was encoded as "X" and "W" was encoded as a space.

#### ROT13

ROT13 is a simple cipher that replaces each letter with the letter 13 letters ahead in the English alphabet. It is a reciprocal cipher, so all letters in the ROT13 column become the corresponding letters in the Letter column. Uppercase letters stay uppercase, and lowercase letters stay lowercase.

ROT13
Letter ROT13
A N
B O
C P
D Q
E R
F S
G T
H U
I V
J W
K X
L Y
M Z

## Complex encryption

Complex encryption systems generally return a fixed length string, no matter how long the input is. These kinds of encryptions, often called hashes, are widely used to securely store passwords in a database.

## Encryption in Scratch

Encryption can be used in lists in Scratch. Suppose a list contains numbers, but one wants those values to be hidden in an encrypted way. A simple method would be the following script:

```set [item# v] to (1) //begin the encryption with the first value
repeat (length of [values v]) //repeat for the amount of numbers that are to be encrypted
replace item (item#) of [values v] with (((item (item#) of [values v]) * (2.463)) + (7.293)) //simple algorithm for encryption
change [item# v] by (1) //move on to the next value in the list
```

Then, to decrypt the values, the algorithm must be reversed:

```set [item# v] to (1)
repeat (length of [values v])
replace item (item#) of [values v] with (((item (item#) of [values v]) - (7.293)) / (2.463))
change [item# v] by (1)
```

Complex numbers with multiple decimal places are used for greater difficulty in deciphering the code. The more mathematical functions and complex numbers are used, the safer the encryption is. Encrypting values in a Scratch project can be difficult to do safely, though, since a user can See Inside and view the encryptor itself. However, if the decipher algorithm is not visible, it may still be difficult do decipher the codes if an intricate algorithm or method was used.

 Warning: No personal information should ever be entered into a Scratch project, even if it is encrypted.

## References

Cookies help us deliver our services. By using our services, you agree to our use of cookies.