305 |
306 | So we know that `A` correspond to `65` in decimal (base 10).
307 |
308 | ### Convert decimal to Binary
309 | - Take any number `N`.
310 |
311 | - Keep dividing `N` by `2` and write down the remainder (`0` or `1`)
312 | - Reverse the list of remainder
313 |
314 | - Add padding `0`s at the beginning, so for example if we have `101` and we want an 8-bit stream, we output `00000101`.
315 |
316 | # What you need to do?
317 | Using this explanation, write a program that can **decode** 8 bit stream.
318 |
319 | ## Requirements
320 | - Your program should handle stream where there are no space between 8 bit numbers.
321 | - You should use the following template:
322 | ```js
323 | String.prototype.decrypt = function() {
324 | // to get the String you need to encrypt, use 'this'
325 | }
326 | ```
327 |
--------------------------------------------------------------------------------
/challenges/bitshift-encrypt.md:
--------------------------------------------------------------------------------
1 | # BitShift Cipher
2 | ## How it works
3 |
4 | ### Encoding
5 |
6 | The Bitshift Cipher works by (as the name suggests) shifting over the bits of the text's ASCII. We do this using the bitwise `<<` operator, which is used to shift the bits a certain number of places.
7 |
8 | To encode the text, we loop through the text, and for each character `x`, we loop through the key array, and for each key character `i`:
9 |
10 | ```py
11 | x = x + 1 << i % 8
12 | ```
13 |
14 | We limit the maximum shift using modulo to avoid having a bit shifted by hundreds of places
15 |
16 | Example:
17 |
18 | Let's imagine we are currently working on the character `A`, and that our key is `YO`
19 |
20 | ```Python
21 | A = 0b01000001 # ASCII for A
22 | 0b01000010 # plus 1
23 | 0b010000100 # Y is 89, 89 % 8 = 1, so we add 1 zero.
24 | # next charachter in key: O
25 | 0b010000101 # plus 1
26 | 0b0100001010000000 # O is 79, 79 % 8 = 7, so we add 7 zeros.
27 | ```
28 |
29 | After each character is encoded, we add it to an array and reverse the key to make frequency analysis harder.
30 |
31 | Let's say the next character in our string is `B`, our key now is `OY`, as it was reversed.
32 |
33 | ```Python
34 | B = 0b01000010 # ASCII for B
35 | 0b01000011 # plus 1
36 | 0b010000110000000 # O is 79, 79 % 8 = 7, so we add 7 zeros.
37 | # next character in key: Y
38 | 0b010000110000001 # plus 1
39 | 0b0100001100000010 # Y is 89, 89 % 8 = 1, so we add 1 zero.
40 | ```
41 |
42 | Our array now looks like this: `[0b0100001010000000, 0b0100001100000010]`, or in decimal: `[17024, 17154]`.
43 |
44 | Finally, we encode the array in base64 to get the final encrypted string: `'WzE3MDI0LCAxNzE1NF0='`.
45 |
46 | # What you need to do
47 |
48 | **Using this explanation, recreate a function that encrypts a phrase such as `Hello World!` using any key**
49 |
50 | ## Requirements:
51 |
52 | - Your program should use this template:
53 |
54 | ```javascript
55 | String.prototype.encrypt = function(key) {
56 | // to get the String you need to encrypt, use 'this'
57 | }
58 | ```
59 |
--------------------------------------------------------------------------------
/challenges/caesar-decrypt.md:
--------------------------------------------------------------------------------
1 | # Caesar Cipher
2 |
3 | ## History and usage
4 |
5 | The _Caesar Cipher_ was named after Julius Caesar (100 B.C. – 44 B.C). He would use the cipher for secret communication (protect messages of military significance). The Caesar Cipher is a **substitution cipher**. Originally, Julius Caesar would use a shift of three to encrypt/decrypt a message. The Caesar Cipher encrypts a message using an affine function : f(x) = 1x + b.
6 |
7 | ## Detailed Explanations : How it works?
8 |
9 | 1. Firstly, each character of the initial text (message to encrypt) is converted in a number from 0 to 25, corresponding to its position in the Latin alphabet which contains 26 letters --> (a = 0, b = 1 ... z = 25 ).
10 |
11 | 2. Then, each number obtained is transformed by an affine function (f(x) = 1x + b). "x" is representing the number while "b" is defined during the encryption. "b" is the key used to decrypt the final message.
12 |
13 | 3. If we take all the images and put them in a list, we obtain n numbers corresponding to n characters of the initial text. The next step consists in finding the values of modulo 26 of each number. (**Modulo means remainder**)
14 |
15 | > Example : Modulo 4 of 19 is **3** because `19 = 4 * 4 + 3` In the other hand, modulo 26 of 26 is **0** because `26 = 26 * 1 + 0`
16 |
17 | 1. Therefore, we obtain a new list with n element, each between 0 and 25 both included. All these numbers are converted in letters of the Latin Alphabet using the tables below.
18 |
19 | 2. We finally create the final message by putting all the letters side by side.
20 |
21 | Steps 1 and 4 can be done with these tables :
22 |
23 |
24 |
25 |
26 |
A
27 |
B
28 |
C
29 |
D
30 |
E
31 |
F
32 |
G
33 |
H
34 |
I
35 |
J
36 |
K
37 |
L
38 |
M
39 |
N
40 |
O
41 |
P
42 |
Q
43 |
R
44 |
S
45 |
T
46 |
U
47 |
V
48 |
W
49 |
X
50 |
Y
51 |
Z
52 |
53 |
54 |
55 |
56 |
0
57 |
1
58 |
2
59 |
3
60 |
4
61 |
5
62 |
6
63 |
7
64 |
8
65 |
9
66 |
10
67 |
11
68 |
12
69 |
13
70 |
14
71 |
15
72 |
16
73 |
17
74 |
18
75 |
19
76 |
20
77 |
21
78 |
22
79 |
23
80 |
24
81 |
25
82 |
83 |
84 |
85 |
86 | # What you need to do:
87 |
88 | **Using this explanation, recreate a function that decrypts a word previously encrypted such as `LIPPS` using any key**
89 |
90 | ## Requirements:
91 |
92 | - Your program should be case insensitive, and return only upper cased letters.
93 | - Your program should use this template:
94 |
95 | ```javascript
96 | String.prototype.decrypt = function(key) {
97 | // to get the String you need to decrypt, use 'this'
98 | }
99 | ```
100 |
--------------------------------------------------------------------------------
/challenges/caesar-encrypt.md:
--------------------------------------------------------------------------------
1 | # Caesar Cipher
2 |
3 | ## History and usage
4 |
5 | The _Caesar Cipher_ was named after Julius Caesar (100 B.C. – 44 B.C). He would use the cipher for secret communication (protect messages of military significance). The Caesar Cipher is a **substitution cipher**. Originally, Julius Caesar would use a shift of three to encrypt/decrypt a message. The Caesar Cipher encrypts a message using an affine function : f(x) = 1x + b.
6 |
7 | ## Detailed Explanations : How it works?
8 |
9 | 1. Firstly, each character of the initial text (message to encrypt) is converted in a number from 0 to 25, corresponding to its position in the Latin alphabet which contains 26 letters --> (a = 0, b = 1 ... z = 25 ).
10 |
11 | 2. Then, each number obtained is transformed by an affine function (f(x) = 1x + b). "x" is representing the number while "b" is defined during the encryption. "b" is the key used to decrypt the final message.
12 |
13 | 3. If we take all the images and put them in a list, we obtain n numbers corresponding to n characters of the initial text. The next step consists in finding the values of modulo 26 of each number. (**Modulo means remainder**)
14 |
15 | > Example : Modulo 4 of 19 is **3** because `19 = 4 * 4 + 3` In the other hand, modulo 26 of 26 is **0** because `26 = 26 * 1 + 0`
16 |
17 | 1. Therefore, we obtain a new list with n element, each between 0 and 25 both included. All these numbers are converted in letters of the Latin Alphabet using the tables below.
18 |
19 | 2. We finally create the final message by putting all the letters side by side.
20 |
21 | Steps 1 and 4 can be done with these tables :
22 |
23 |
24 |
25 |
26 |
A
27 |
B
28 |
C
29 |
D
30 |
E
31 |
F
32 |
G
33 |
H
34 |
I
35 |
J
36 |
K
37 |
L
38 |
M
39 |
N
40 |
O
41 |
P
42 |
Q
43 |
R
44 |
S
45 |
T
46 |
U
47 |
V
48 |
W
49 |
X
50 |
Y
51 |
Z
52 |
53 |
54 |
55 |
56 |
0
57 |
1
58 |
2
59 |
3
60 |
4
61 |
5
62 |
6
63 |
7
64 |
8
65 |
9
66 |
10
67 |
11
68 |
12
69 |
13
70 |
14
71 |
15
72 |
16
73 |
17
74 |
18
75 |
19
76 |
20
77 |
21
78 |
22
79 |
23
80 |
24
81 |
25
82 |
83 |
84 |
85 |
86 | # What you need to do:
87 |
88 | **Using this explanation, recreate a function that encrypts a word such as `Hello` using any key**
89 |
90 | ## Requirements:
91 |
92 | - Your program should be case insensitive, and return only upper cased letters.
93 | - Your program should use this template:
94 |
95 | ```javascript
96 | String.prototype.encrypt = function(key) {
97 | // to get the String you need to encrypt, use 'this'
98 | }
99 | ```
100 |
--------------------------------------------------------------------------------
/challenges/emojigraphy.md:
--------------------------------------------------------------------------------
1 | ## Introduction
2 | This is the first challenge of this platform. It's pretty easy, but don't worry, it will get harder in
3 | the next challenges.
4 |
5 | ### Tutorial:
6 | - On this section, you'll always see the 'course' and the challenge that you need to do
7 | - On the upper right corner, there is the code editor. This is where you'll write your answer (in JavaScript of course).
8 | - On the lower right corner, you'll see the console. This is where you'll know if you failed or not.
9 | > **ProTips 💡:**
10 | - Press `Ctrl+Enter` (or `Cmd + Enter` on macOS) to execute your code right from the editor.
11 | - Press `Shift+Enter` to enter full screen mode. (Press `Esc` to exit)
12 | - Press `Ctrl+Shift+C` (or `Cmd + Shift + C` on macOS) to clear the console
13 |
14 | # Emoji cipher
15 |
16 | The Emoji cipher is a very basic cipher.
17 |
18 | Basically, we convert letters to emojis to encode a message, and we do the opposite operation to decode this encrypted message.
19 |
20 | Here is the table:
21 |
22 |
23 |
24 |
A
25 |
B
26 |
C
27 |
D
28 |
E
29 |
F
30 |
G
31 |
H
32 |
I
33 |
J
34 |
K
35 |
L
36 |
M
37 |
N
38 |
O
39 |
P
40 |
Q
41 |
R
42 |
S
43 |
T
44 |
U
45 |
V
46 |
W
47 |
X
48 |
Y
49 |
Z
50 |
51 |
52 |
53 |
54 |
😄
55 |
😃
56 |
😀
57 |
😊
58 |
😅
59 |
😉
60 |
😍
61 |
😘
62 |
😚
63 |
😗
64 |
😙
65 |
😜
66 |
😝
67 |
😛
68 |
😳
69 |
😁
70 |
😔
71 |
😌
72 |
😒
73 |
😞
74 |
😣
75 |
😢
76 |
😂
77 |
😭
78 |
😎
79 |
😈
80 |
81 |
82 |
83 |
84 | # What you need to do
85 |
86 | **Using this explanation, recreate a function that encrypts a word such as `Hello` using any key**
87 |
88 | ## Requirements:
89 |
90 | - Your program should be case insensitive.
91 | - Your program should use this template:
92 |
93 | ```javascript
94 | String.prototype.encrypt = function() {
95 | // to get the String you need to encrypt, use 'this'
96 | }
97 | ```
98 |
--------------------------------------------------------------------------------
/challenges/hashshift.md:
--------------------------------------------------------------------------------
1 | # HashShift
2 |
3 | ## How it works?
4 |
5 | > We'll use the Swift implementation to describe what we're doing
6 |
7 | First, let's take a seed for our generator:
8 |
9 | ```swift
10 | var seed = 12
11 | ```
12 |
13 | Then let's hash his `String` representation:
14 |
15 | ```swift
16 | let hash = String(seed).sha256
17 | ```
18 |
19 | Now, we'll take the `10` first characters of the outputed hex digest:
20 |
21 | ```swift
22 | let first = hash.prefix(10)
23 | ```
24 |
25 | Now we have a `hex` representation of a number in a `String`, let's parse it:
26 |
27 | ```swift
28 | let n = Int(first, radix: 16)
29 | ```
30 |
31 | Then, we rotate `n` like:
32 |
33 | ```swift
34 | let r = (n! >> 13 * seed) % 99371 // for non-swift developers, 'n!' doesn't mean n factorial but the unwrapped value of n
35 | ```
36 |
37 | And we change the `seed`:
38 |
39 | ```swift
40 | seed = (r ^ n! << 2 + n!) % 70937
41 | ```
42 |
43 | Finally we output the absolute value as `Float` of `r` divided by `99371` to have a number between `0` and `1`:
44 |
45 | ```swift
46 | return Float(abs(r)) / 99371
47 | ```
48 |
49 | # What you need to do:
50 |
51 | **Using this explanation, create a HashShift PRNG generator.**
52 |
53 | ## Requirements:
54 | - Your program should use this template:
55 |
56 | ```javascript
57 | String.prototype.sha256=function(){let r=this;const n=8,t=0;function e(r,n){const t=(65535&r)+(65535&n);return(r>>16)+(n>>16)+(t>>16)<<16|65535&t}function o(r,n){return r>>>n|r<<32-n}function u(r,n){return r>>>n}function c(r,n,t){return r&n^~r&t}function f(r,n,t){return r&n^r&t^n&t}function i(r){return o(r,2)^o(r,13)^o(r,22)}function a(r){return o(r,6)^o(r,11)^o(r,25)}function h(r){return o(r,7)^o(r,18)^u(r,3)}return function(r){const n=t?"0123456789ABCDEF":"0123456789abcdef";let e="";for(let t=0;t<4*r.length;t++)e+=n.charAt(r[t>>2]>>8*(3-t%4)+4&15)+n.charAt(r[t>>2]>>8*(3-t%4)&15);return e}(function(r,n){const t=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),C=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),g=new Array(64);let l,d,A,s,S,m,y,p,v,w;r[n>>5]|=128<<24-n%32,r[15+(n+64>>9<<4)]=n;for(var b=0;b>5]|=(r.charCodeAt(o/n)&e)<<24-o%32;return t}(r=function(r){r=r.replace(/\r\n/g,"\n");let n="";for(let t=0;t127&&e<2048?(n+=String.fromCharCode(e>>6|192),n+=String.fromCharCode(63&e|128)):(n+=String.fromCharCode(e>>12|224),n+=String.fromCharCode(e>>6&63|128),n+=String.fromCharCode(63&e|128))}return n}(r)),r.length*n))};
58 |
59 | // To use SHA256, do something like: "some text".sha256()
60 |
61 | function* rand(seed) {
62 | while (true) {
63 | yield out // out is the outtputed number.
64 | }
65 | }
66 | ```
67 |
--------------------------------------------------------------------------------
/challenges/inverse.md:
--------------------------------------------------------------------------------
1 | # Question:
2 | If FIND is coded as URMW and ME is coded as NV, then **create a function that will reproduce this effect on any string**
3 |
4 | ## Help?
5 | You should look at this alphabet table:
6 |
7 |
8 |
9 |
10 |
A
11 |
B
12 |
C
13 |
D
14 |
E
15 |
F
16 |
G
17 |
H
18 |
I
19 |
J
20 |
K
21 |
L
22 |
M
23 |
N
24 |
O
25 |
P
26 |
Q
27 |
R
28 |
S
29 |
T
30 |
U
31 |
V
32 |
W
33 |
X
34 |
Y
35 |
Z
36 |
37 |
38 |
39 |
40 | ## Requirements:
41 |
42 | - Your program should be case **insensitive**, and return capital letters only.
43 | - Your program should use this template:
44 |
45 | ```javascript
46 | String.prototype.encrypt = function() {
47 | // to get the String you need to encrypt, use 'this'
48 | }
49 | ```
50 |
--------------------------------------------------------------------------------
/challenges/lost.md:
--------------------------------------------------------------------------------
1 | # Concept of Hash
2 | A cryptographic hash function is a special class of hash function that has certain properties which make it suitable for use in cryptography.
3 |
4 | It is a mathematical algorithm that maps data of arbitrary size to a bit string of a fixed size (a hash) and is designed to be a one-way function, that is, a function which is infeasible to invert.
5 |
6 | The only way to recreate the input data from an ideal cryptographic hash function's output is to attempt a brute-force search of possible inputs to see if they produce a match, or use a rainbow table of matched hashes.
7 |
8 | Bruce Schneier has called one-way hash functions "the workhorses of modern cryptography". The input data is often called the message, and the output (the hash value or hash) is often called the message digest or simply the digest.
9 |
10 | The ideal cryptographic hash function has five main properties:
11 |
12 | - it is deterministic so the same message always results in the same hash
13 | - it is quick to compute the hash value for any given message
14 | - it is infeasible to generate a message from its hash value except by trying all possible messages
15 | - a small change to a message should change the hash value so extensively that the new hash value appears - uncorrelated with the old hash value
16 | - it is infeasible to find two different messages with the same hash value
17 |
18 | # Problem
19 | At CrypTools, one of our admin forgot his password, but GitHub was able to obtain and give us a `SHA256` hash of his password:
20 | ```
21 | 88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589
22 | ```
23 | Hopefully, he remember that his password is only 4 letters long and that his password was made of lower cased letters.
24 |
25 | # What you need to do?
26 | Using the hash function `SHA256` that we provide, create a function that will brute force the hash and will output the password.
27 | ## Requirements:
28 | - Your program should use this template:
29 |
30 | ```javascript
31 | String.prototype.sha256=function(){let r=this;const n=8,t=0;function e(r,n){const t=(65535&r)+(65535&n);return(r>>16)+(n>>16)+(t>>16)<<16|65535&t}function o(r,n){return r>>>n|r<<32-n}function u(r,n){return r>>>n}function c(r,n,t){return r&n^~r&t}function f(r,n,t){return r&n^r&t^n&t}function i(r){return o(r,2)^o(r,13)^o(r,22)}function a(r){return o(r,6)^o(r,11)^o(r,25)}function h(r){return o(r,7)^o(r,18)^u(r,3)}return function(r){const n=t?"0123456789ABCDEF":"0123456789abcdef";let e="";for(let t=0;t<4*r.length;t++)e+=n.charAt(r[t>>2]>>8*(3-t%4)+4&15)+n.charAt(r[t>>2]>>8*(3-t%4)&15);return e}(function(r,n){const t=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),C=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),g=new Array(64);let l,d,A,s,S,m,y,p,v,w;r[n>>5]|=128<<24-n%32,r[15+(n+64>>9<<4)]=n;for(var b=0;b>5]|=(r.charCodeAt(o/n)&e)<<24-o%32;return t}(r=function(r){r=r.replace(/\r\n/g,"\n");let n="";for(let t=0;t127&&e<2048?(n+=String.fromCharCode(e>>6|192),n+=String.fromCharCode(63&e|128)):(n+=String.fromCharCode(e>>12|224),n+=String.fromCharCode(e>>6&63|128),n+=String.fromCharCode(63&e|128))}return n}(r)),r.length*n))};
32 |
33 | // To use SHA256, do something like: "some text".sha256()
34 | function bruteforce() {
35 | const hash = "88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589"
36 | }
37 | ```
38 |
--------------------------------------------------------------------------------
/challenges/railfence-encoding.md:
--------------------------------------------------------------------------------
1 | # Railfence Cipher
2 |
3 | A transposition cipher also called the zigzag cipher.
4 |
5 | ## How it works
6 |
7 | ### Encoding
8 |
9 | The Rail Fence Cipher places the letters in a zigzag pattern before reading them again, from top to bottom, right to left, ignoring the zigzag.
10 |
11 | Example:
12 |
13 | Let's imagine that we are encoding `Hello World!` on 3 rails. we draw out our three rails and place the lettres in the zigzag pattern like this:
14 |
15 | ```txt
16 | H - - - o - - - r - - -
17 | - e - l - - o - l - !
18 | - - l - - - w - - - d -
19 | ```
20 |
21 | When this is read top to bottom, left to right, we get `Horel ol!lwd`
22 |
23 | ## Requirements:
24 |
25 | - Your program should be case **sensitive** and should support any Unicode symbols
26 | - Your program should use this template:
27 |
28 | ```javascript
29 | String.prototype.encrypt = function(key) { // key is the number of rails
30 | // to get the String you need to encrypt, use 'this'
31 | }
32 | ```
33 |
--------------------------------------------------------------------------------
/challenges/rot13.md:
--------------------------------------------------------------------------------
1 | # ROT13
2 |
3 | A stupidly simple reversible substitution cipher.
4 |
5 | > ROT13 was in use in the net.jokes newsgroup by the early 1980s. It is used to hide potentially offensive jokes, or to obscure an answer to a puzzle or other spoiler. - Wikipedia
6 |
7 | # How it works
8 |
9 | ## Encoding
10 |
11 | The ROT13 cipher will substitute each letter by the letter coming 13 places after it in the alphabet. According to this logic, N should map to the 27th character of the alphabet, but we only have 26 characters, so we loop the alphabet around. We now have the formula `ROT13(c) = (c + 13) % 26`, where c is the position in the alphabet of a given character.
12 |
13 | Therefore, `A => N, B => O, ..., M => Z, N => A`
14 |
15 | When encoding a string, we replace uppercase characters with their uppercase mirror, lowercase character with their lowercase mirror, and leave all other characters untouched.
16 |
17 | To help us with the encoding process, we create a lookup table like this:
18 |
19 |
20 |
21 |
22 |
A
23 |
B
24 |
C
25 |
D
26 |
E
27 |
F
28 |
G
29 |
H
30 |
I
31 |
J
32 |
K
33 |
L
34 |
M
35 |
36 |
37 |
38 |
39 |
N
40 |
O
41 |
P
42 |
Q
43 |
R
44 |
S
45 |
T
46 |
U
47 |
V
48 |
W
49 |
X
50 |
Y
51 |
Z
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
N
60 |
O
61 |
P
62 |
Q
63 |
R
64 |
S
65 |
T
66 |
U
67 |
V
68 |
W
69 |
X
70 |
Y
71 |
Z
72 |
73 |
74 |
75 |
76 |
A
77 |
B
78 |
C
79 |
D
80 |
E
81 |
F
82 |
G
83 |
H
84 |
I
85 |
J
86 |
K
87 |
L
88 |
M
89 |
90 |
91 |
92 | Example:
93 |
94 | Let's encode the string `Hello World!`. We need to lookup each character in our table, and then write down its image.
95 |
96 | ```
97 | H => U
98 | e => r
99 | l => y
100 | ...
101 | _ => _ # space maps to space.
102 | W => J
103 | ...
104 | ! => !
105 | ```
106 |
107 | Our final encoded string is `Urryb Jbeyq!`.
108 |
109 | ## Decoding
110 |
111 | As you might have noticed from the lookup table, `ROT13(ROT13(c)) = c`. This cipher is therefore reversible, and to decode, we just need to go through the whole encoding process once more.
112 |
113 | Example:
114 |
115 | Our encoded output was `Urryb Jbeyq!`. We need to lookup each character in our table, and then write down its image.
116 |
117 | ```
118 | U => H
119 | r => e
120 | y => l
121 | ...
122 | _ => _ # space maps to space.
123 | J => W
124 | ...
125 | ! => !
126 | ```
127 |
128 | Our final decoded string is `Hello World!`.
129 |
130 |
131 | # What you need to do:
132 | **Using this explanation, recreate a function that encrypts a word such as `Hello`**
133 |
134 | ## Requirements:
135 | - Your program should be case insensitive, and return only upper cased letters.
136 | - Your program should use this template:
137 |
138 | ```javascript
139 | String.prototype.encrypt = function() {
140 | // to get the String you need to encrypt, use 'this'
141 | }
142 | ```
143 |
--------------------------------------------------------------------------------
/challenges/rsa.md:
--------------------------------------------------------------------------------
1 | # RSA
2 | **The RSA encryption is based on the following procedure:**
3 |
4 | Generate two distinct primes p and q.
5 | Compute `n = pq` and `φ = (p - 1)(q - 1)`.
6 | Find an integer `e`, `1 < e < φ`, such that `gcd(e, φ) = 1`.
7 |
8 | A message in this system is a number in the interval `[0, n - 1]`.
9 | A text to be encrypted is then somehow converted to messages (numbers in the interval `[0, n - 1]`).
10 | To encrypt the text, for each message, `m`, `c = me mod n` is calculated.
11 |
12 | To decrypt the text, the following procedure is needed: calculate `d` such that `ed = 1 mod φ`, then for each encrypted message, `c`, calculate `m = cd mod n`.
13 |
14 | There exist values of `e` and `m` such that `me mod n = m`.
15 | We call messages m for which me mod n=m unconcealed messages.
16 |
17 | An issue when choosing e is that there should not be too many unconcealed messages.
18 | For instance, let `p = 19` and `q = 37`.
19 | Then `n= 19*37 = 703` and `φ = 18*36 = 648`.
20 | If we choose `e=181`, then, although `gcd(181, 648) = 1` it turns out that all possible messages
21 | `m (0 ≤ m ≤ n - 1)` are unconcealed when calculating `me mod n`.
22 | For any valid choice of `e` there exist some unconcealed messages.
23 | > It's important that the number of unconcealed messages is at a minimum.
24 |
25 | # What you need to do:
26 | - Choose `p = 1009` and `q = 3643`.
27 |
28 | Find the sum of all values of e, `1< e <φ(1009,3643)` and `gcd(e, φ) = 1`, so that the number of unconcealed messages for this value of `e` is at a minimum.
29 |
30 | ## Requirements:
31 | - Your program should use this template:
32 |
33 | ```javascript
34 | function rsa() {
35 | return n // n is the answer
36 | }
37 | ```
38 |
--------------------------------------------------------------------------------
/challenges/xorcipher.md:
--------------------------------------------------------------------------------
1 | # XORCipher
2 | A simple adaptive cipher based on the logical XOR operation.
3 |
4 | ## How it works
5 |
6 | ### Encoding
7 |
8 | The XOR cipher will encrypt a message by using the Boolean XOR (exclusive or) operation. A XOR B returns 1 if and only if A and B are different.
9 |
10 |
11 |
12 |
13 |
A
14 |
B
15 |
A XOR B
16 |
17 |
18 |
19 |
20 |
0
21 |
0
22 |
0
23 |
24 |
25 |
0
26 |
1
27 |
1
28 |
29 |
30 |
1
31 |
0
32 |
1
33 |
34 |
35 |
1
36 |
1
37 |
0
38 |
39 |
40 |
41 |
42 | To encrypt a message with a given key, we first convert the string into their ASCII equivalent, and we then XOR every character with the key. For example, if we want to encrypt XOR with 134 as a key, we would do:
43 |
44 | ```txt
45 | X O R
46 | 01011000 01001111 01010010 # String in ASCII
47 | 10000110 10000110 10000110 # Repeating key 134
48 | --------------------------
49 | 11011110 11001001 11010100 # XOR result
50 | Þ É Ô # Result converted back into plain text
51 | ```
52 |
53 | When implemented in JavaScript, we get `char ^ key`.
54 |
55 | As you might have noticed, in this cipher, a given character is always replaced by the same character. This makes frequency analysis easier. To avoid that, we can use a non-repeating key eg. `29, 62, 134`, where we loop through the keys to encode each character.
56 |
57 | ```txt
58 | X O R
59 | 88 79 82
60 | 29 62 134
61 | ----------
62 | 69 113 212
63 | E q Ô
64 | ```
65 |
66 | # What you need to do:
67 |
68 | **Using this explanation, recreate a function that encrypts a word such as `Hello` using any key**
69 |
70 | ## Requirements:
71 |
72 | - Your program should be case insensitive, and return only upper cased letters.
73 | - Your program should use this template:
74 |
75 | ```javascript
76 | String.prototype.encrypt = function(key) { // key is a number or an array
77 | // to get the String you need to encrypt, use 'this'
78 | }
79 | ```
80 |
--------------------------------------------------------------------------------
/css/challenges.scss:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | /*! HTML5 Boilerplate v5.3.0 | MIT License | https://html5boilerplate.com/ */
5 |
6 | /*
7 | * What follows is the result of much research on cross-browser styling.
8 | * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
9 | * Kroc Camen, and the H5BP dev community and team.
10 | */
11 |
12 | /* ==========================================================================
13 | Base styles: opinionated defaults
14 | ========================================================================== */
15 |
16 | html {
17 | color: #222;
18 | font-size: 1em;
19 | line-height: 1.4;
20 | }
21 |
22 | /*
23 | * Remove text-shadow in selection highlight:
24 | * https://twitter.com/miketaylr/status/12228805301
25 | *
26 | * These selection rule sets have to be separate.
27 | * Customize the background color to match your design.
28 | */
29 |
30 | ::-moz-selection {
31 | background: #b3d4fc;
32 | text-shadow: none;
33 | }
34 |
35 | ::selection {
36 | background: #b3d4fc;
37 | text-shadow: none;
38 | }
39 |
40 | /*
41 | * A better looking default horizontal rule
42 | */
43 |
44 | hr {
45 | display: block;
46 | height: 1px;
47 | border: 0;
48 | border-top: 1.5px solid #ccc;
49 | margin: 1em 0;
50 | padding: 0;
51 | }
52 |
53 | /*
54 | * Remove the gap between audio, canvas, iframes,
55 | * images, videos and the bottom of their containers:
56 | * https://github.com/h5bp/html5-boilerplate/issues/440
57 | */
58 |
59 | audio,
60 | canvas,
61 | iframe,
62 | img,
63 | svg,
64 | video {
65 | vertical-align: middle;
66 | }
67 |
68 | /*
69 | * Remove default fieldset styles.
70 | */
71 |
72 | fieldset {
73 | border: 0;
74 | margin: 0;
75 | padding: 0;
76 | }
77 |
78 | /*
79 | * Allow only vertical resizing of textareas.
80 | */
81 |
82 | textarea {
83 | resize: vertical;
84 | }
85 |
86 | /* ==========================================================================
87 | Browser Upgrade Prompt
88 | ========================================================================== */
89 |
90 | .browserupgrade {
91 | margin: 0.2em 0;
92 | background: #ccc;
93 | color: #000;
94 | padding: 0.2em 0;
95 | }
96 |
97 | /* ==========================================================================
98 | Author's custom styles
99 | ========================================================================== */
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 | @import "styles-challenges.scss";
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 | /* ==========================================================================
118 | Helper classes
119 | ========================================================================== */
120 |
121 | /*
122 | * Hide visually and from screen readers
123 | */
124 |
125 | .hidden {
126 | display: none !important;
127 | }
128 |
129 | /*
130 | * Hide only visually, but have it available for screen readers:
131 | * https://snook.ca/archives/html_and_css/hiding-content-for-accessibility
132 | *
133 | * 1. For long content, line feeds are not interpreted as spaces and small width
134 | * causes content to wrap 1 word per line:
135 | * https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
136 | */
137 |
138 | .visuallyhidden {
139 | border: 0;
140 | clip: rect(0 0 0 0);
141 | height: 1px;
142 | margin: -1px;
143 | overflow: hidden;
144 | padding: 0;
145 | position: absolute;
146 | width: 1px;
147 | white-space: nowrap; /* 1 */
148 | }
149 |
150 | /*
151 | * Extends the .visuallyhidden class to allow the element
152 | * to be focusable when navigated to via the keyboard:
153 | * https://www.drupal.org/node/897638
154 | */
155 |
156 | .visuallyhidden.focusable:active,
157 | .visuallyhidden.focusable:focus {
158 | clip: auto;
159 | height: auto;
160 | margin: 0;
161 | overflow: visible;
162 | position: static;
163 | width: auto;
164 | white-space: inherit;
165 | }
166 |
167 | /*
168 | * Hide visually and from screen readers, but maintain layout
169 | */
170 |
171 | .invisible {
172 | visibility: hidden;
173 | }
174 |
175 | /*
176 | * Clearfix: contain floats
177 | *
178 | * For modern browsers
179 | * 1. The space content is one way to avoid an Opera bug when the
180 | * `contenteditable` attribute is included anywhere else in the document.
181 | * Otherwise it causes space to appear at the top and bottom of elements
182 | * that receive the `clearfix` class.
183 | * 2. The use of `table` rather than `block` is only necessary if using
184 | * `:before` to contain the top-margins of child elements.
185 | */
186 |
187 | .clearfix:before,
188 | .clearfix:after {
189 | content: " "; /* 1 */
190 | display: table; /* 2 */
191 | }
192 |
193 | .clearfix:after {
194 | clear: both;
195 | }
196 |
197 | /* ==========================================================================
198 | EXAMPLE Media Queries for Responsive Design.
199 | These examples override the primary ('mobile first') styles.
200 | Modify as content requires.
201 | ========================================================================== */
202 |
203 | @media only screen and (min-width: 35em) {
204 | /* Style adjustments for viewports that meet the condition */
205 | }
206 |
207 | @media print,
208 | (-webkit-min-device-pixel-ratio: 1.25),
209 | (min-resolution: 1.25dppx),
210 | (min-resolution: 120dpi) {
211 | /* Style adjustments for high resolution devices */
212 | }
213 |
214 | /* ==========================================================================
215 | Print styles.
216 | Inlined to avoid the additional HTTP request:
217 | http://www.phpied.com/delay-loading-your-print-css/
218 | ========================================================================== */
219 |
220 | @media print {
221 | *,
222 | *:before,
223 | *:after,
224 | p:first-letter,
225 | div:first-letter,
226 | blockquote:first-letter,
227 | li:first-letter,
228 | p:first-line,
229 | div:first-line,
230 | blockquote:first-line,
231 | li:first-line {
232 | background: transparent !important;
233 | color: #000 !important; /* Black prints faster:
234 | http://www.sanbeiji.com/archives/953 */
235 | box-shadow: none !important;
236 | text-shadow: none !important;
237 | }
238 |
239 | a,
240 | a:visited {
241 | text-decoration: underline;
242 | }
243 |
244 | a[href]:after {
245 | content: " (" attr(href) ")";
246 | }
247 |
248 | abbr[title]:after {
249 | content: " (" attr(title) ")";
250 | }
251 |
252 | /*
253 | * Don't show links that are fragment identifiers,
254 | * or use the `javascript:` pseudo protocol
255 | */
256 |
257 | a[href^="#"]:after,
258 | a[href^="javascript:"]:after {
259 | content: "";
260 | }
261 |
262 | pre {
263 | white-space: pre-wrap !important;
264 | }
265 | pre,
266 | blockquote {
267 | border: 1px solid #999;
268 | page-break-inside: avoid;
269 | }
270 |
271 | /*
272 | * Printing Tables:
273 | * http://css-discuss.incutio.com/wiki/Printing_Tables
274 | */
275 |
276 | thead {
277 | display: table-header-group;
278 | }
279 |
280 | tr,
281 | img {
282 | page-break-inside: avoid;
283 | }
284 |
285 | p,
286 | h2,
287 | h3 {
288 | orphans: 3;
289 | widows: 3;
290 | }
291 |
292 | h2,
293 | h3 {
294 | page-break-after: avoid;
295 | }
296 | }
297 |
--------------------------------------------------------------------------------
/css/main.scss:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | /*! HTML5 Boilerplate v5.3.0 | MIT License | https://html5boilerplate.com/ */
5 |
6 | /*
7 | * What follows is the result of much research on cross-browser styling.
8 | * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
9 | * Kroc Camen, and the H5BP dev community and team.
10 | */
11 |
12 | /* ==========================================================================
13 | Base styles: opinionated defaults
14 | ========================================================================== */
15 |
16 | html {
17 | color: #222;
18 | font-size: 1em;
19 | line-height: 1.4;
20 | }
21 |
22 | /*
23 | * Remove text-shadow in selection highlight:
24 | * https://twitter.com/miketaylr/status/12228805301
25 | *
26 | * These selection rule sets have to be separate.
27 | * Customize the background color to match your design.
28 | */
29 |
30 | ::-moz-selection {
31 | background: #b3d4fc;
32 | text-shadow: none;
33 | }
34 |
35 | ::selection {
36 | background: #b3d4fc;
37 | text-shadow: none;
38 | }
39 |
40 | /*
41 | * A better looking default horizontal rule
42 | */
43 |
44 | hr {
45 | display: block;
46 | height: 1px;
47 | border: 0;
48 | border-top: 1.5px solid #ccc;
49 | margin: 1em 0;
50 | padding: 0;
51 | }
52 |
53 | /*
54 | * Remove the gap between audio, canvas, iframes,
55 | * images, videos and the bottom of their containers:
56 | * https://github.com/h5bp/html5-boilerplate/issues/440
57 | */
58 |
59 | audio,
60 | canvas,
61 | iframe,
62 | img,
63 | svg,
64 | video {
65 | vertical-align: middle;
66 | }
67 |
68 | /*
69 | * Remove default fieldset styles.
70 | */
71 |
72 | fieldset {
73 | border: 0;
74 | margin: 0;
75 | padding: 0;
76 | }
77 |
78 | /*
79 | * Allow only vertical resizing of textareas.
80 | */
81 |
82 | textarea {
83 | resize: vertical;
84 | }
85 |
86 | /* ==========================================================================
87 | Browser Upgrade Prompt
88 | ========================================================================== */
89 |
90 | .browserupgrade {
91 | margin: 0.2em 0;
92 | background: #ccc;
93 | color: #000;
94 | padding: 0.2em 0;
95 | }
96 |
97 | /* ==========================================================================
98 | Author's custom styles
99 | ========================================================================== */
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 | @import "styles.scss";
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 | /* ==========================================================================
118 | Helper classes
119 | ========================================================================== */
120 |
121 | /*
122 | * Hide visually and from screen readers
123 | */
124 |
125 | .hidden {
126 | display: none !important;
127 | }
128 |
129 | /*
130 | * Hide only visually, but have it available for screen readers:
131 | * https://snook.ca/archives/html_and_css/hiding-content-for-accessibility
132 | *
133 | * 1. For long content, line feeds are not interpreted as spaces and small width
134 | * causes content to wrap 1 word per line:
135 | * https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
136 | */
137 |
138 | .visuallyhidden {
139 | border: 0;
140 | clip: rect(0 0 0 0);
141 | height: 1px;
142 | margin: -1px;
143 | overflow: hidden;
144 | padding: 0;
145 | position: absolute;
146 | width: 1px;
147 | white-space: nowrap; /* 1 */
148 | }
149 |
150 | /*
151 | * Extends the .visuallyhidden class to allow the element
152 | * to be focusable when navigated to via the keyboard:
153 | * https://www.drupal.org/node/897638
154 | */
155 |
156 | .visuallyhidden.focusable:active,
157 | .visuallyhidden.focusable:focus {
158 | clip: auto;
159 | height: auto;
160 | margin: 0;
161 | overflow: visible;
162 | position: static;
163 | width: auto;
164 | white-space: inherit;
165 | }
166 |
167 | /*
168 | * Hide visually and from screen readers, but maintain layout
169 | */
170 |
171 | .invisible {
172 | visibility: hidden;
173 | }
174 |
175 | /*
176 | * Clearfix: contain floats
177 | *
178 | * For modern browsers
179 | * 1. The space content is one way to avoid an Opera bug when the
180 | * `contenteditable` attribute is included anywhere else in the document.
181 | * Otherwise it causes space to appear at the top and bottom of elements
182 | * that receive the `clearfix` class.
183 | * 2. The use of `table` rather than `block` is only necessary if using
184 | * `:before` to contain the top-margins of child elements.
185 | */
186 |
187 | .clearfix:before,
188 | .clearfix:after {
189 | content: " "; /* 1 */
190 | display: table; /* 2 */
191 | }
192 |
193 | .clearfix:after {
194 | clear: both;
195 | }
196 |
197 | /* ==========================================================================
198 | EXAMPLE Media Queries for Responsive Design.
199 | These examples override the primary ('mobile first') styles.
200 | Modify as content requires.
201 | ========================================================================== */
202 |
203 | @media only screen and (min-width: 35em) {
204 | /* Style adjustments for viewports that meet the condition */
205 | }
206 |
207 | @media print,
208 | (-webkit-min-device-pixel-ratio: 1.25),
209 | (min-resolution: 1.25dppx),
210 | (min-resolution: 120dpi) {
211 | /* Style adjustments for high resolution devices */
212 | }
213 |
214 | /* ==========================================================================
215 | Print styles.
216 | Inlined to avoid the additional HTTP request:
217 | http://www.phpied.com/delay-loading-your-print-css/
218 | ========================================================================== */
219 |
220 | @media print {
221 | *,
222 | *:before,
223 | *:after,
224 | p:first-letter,
225 | div:first-letter,
226 | blockquote:first-letter,
227 | li:first-letter,
228 | p:first-line,
229 | div:first-line,
230 | blockquote:first-line,
231 | li:first-line {
232 | background: transparent !important;
233 | color: #000 !important; /* Black prints faster:
234 | http://www.sanbeiji.com/archives/953 */
235 | box-shadow: none !important;
236 | text-shadow: none !important;
237 | }
238 |
239 | a,
240 | a:visited {
241 | text-decoration: underline;
242 | }
243 |
244 | a[href]:after {
245 | content: " (" attr(href) ")";
246 | }
247 |
248 | abbr[title]:after {
249 | content: " (" attr(title) ")";
250 | }
251 |
252 | /*
253 | * Don't show links that are fragment identifiers,
254 | * or use the `javascript:` pseudo protocol
255 | */
256 |
257 | a[href^="#"]:after,
258 | a[href^="javascript:"]:after {
259 | content: "";
260 | }
261 |
262 | pre {
263 | white-space: pre-wrap !important;
264 | }
265 | pre,
266 | blockquote {
267 | border: 1px solid #999;
268 | page-break-inside: avoid;
269 | }
270 |
271 | /*
272 | * Printing Tables:
273 | * http://css-discuss.incutio.com/wiki/Printing_Tables
274 | */
275 |
276 | thead {
277 | display: table-header-group;
278 | }
279 |
280 | tr,
281 | img {
282 | page-break-inside: avoid;
283 | }
284 |
285 | p,
286 | h2,
287 | h3 {
288 | orphans: 3;
289 | widows: 3;
290 | }
291 |
292 | h2,
293 | h3 {
294 | page-break-after: avoid;
295 | }
296 | }
297 |
--------------------------------------------------------------------------------
/css/noob.scss:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | /*! HTML5 Boilerplate v5.3.0 | MIT License | https://html5boilerplate.com/ */
5 |
6 | /*
7 | * What follows is the result of much research on cross-browser styling.
8 | * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
9 | * Kroc Camen, and the H5BP dev community and team.
10 | */
11 |
12 | /* ==========================================================================
13 | Base styles: opinionated defaults
14 | ========================================================================== */
15 |
16 | html {
17 | color: #222;
18 | font-size: 1em;
19 | line-height: 1.4;
20 | }
21 |
22 | /*
23 | * Remove text-shadow in selection highlight:
24 | * https://twitter.com/miketaylr/status/12228805301
25 | *
26 | * These selection rule sets have to be separate.
27 | * Customize the background color to match your design.
28 | */
29 |
30 | ::-moz-selection {
31 | background: #b3d4fc;
32 | text-shadow: none;
33 | }
34 |
35 | ::selection {
36 | background: #b3d4fc;
37 | text-shadow: none;
38 | }
39 |
40 | /*
41 | * A better looking default horizontal rule
42 | */
43 |
44 | hr {
45 | display: block;
46 | height: 1px;
47 | border: 0;
48 | border-top: 1.5px solid #ccc;
49 | margin: 1em 0;
50 | padding: 0;
51 | }
52 |
53 | /*
54 | * Remove the gap between audio, canvas, iframes,
55 | * images, videos and the bottom of their containers:
56 | * https://github.com/h5bp/html5-boilerplate/issues/440
57 | */
58 |
59 | audio,
60 | canvas,
61 | iframe,
62 | img,
63 | svg,
64 | video {
65 | vertical-align: middle;
66 | }
67 |
68 | /*
69 | * Remove default fieldset styles.
70 | */
71 |
72 | fieldset {
73 | border: 0;
74 | margin: 0;
75 | padding: 0;
76 | }
77 |
78 | /*
79 | * Allow only vertical resizing of textareas.
80 | */
81 |
82 | textarea {
83 | resize: vertical;
84 | }
85 |
86 | /* ==========================================================================
87 | Browser Upgrade Prompt
88 | ========================================================================== */
89 |
90 | .browserupgrade {
91 | margin: 0.2em 0;
92 | background: #ccc;
93 | color: #000;
94 | padding: 0.2em 0;
95 | }
96 |
97 | /* ==========================================================================
98 | Author's custom styles
99 | ========================================================================== */
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 | @import "styles-noob.scss";
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 | /* ==========================================================================
118 | Helper classes
119 | ========================================================================== */
120 |
121 | /*
122 | * Hide visually and from screen readers
123 | */
124 |
125 | .hidden {
126 | display: none !important;
127 | }
128 |
129 | /*
130 | * Hide only visually, but have it available for screen readers:
131 | * https://snook.ca/archives/html_and_css/hiding-content-for-accessibility
132 | *
133 | * 1. For long content, line feeds are not interpreted as spaces and small width
134 | * causes content to wrap 1 word per line:
135 | * https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
136 | */
137 |
138 | .visuallyhidden {
139 | border: 0;
140 | clip: rect(0 0 0 0);
141 | height: 1px;
142 | margin: -1px;
143 | overflow: hidden;
144 | padding: 0;
145 | position: absolute;
146 | width: 1px;
147 | white-space: nowrap; /* 1 */
148 | }
149 |
150 | /*
151 | * Extends the .visuallyhidden class to allow the element
152 | * to be focusable when navigated to via the keyboard:
153 | * https://www.drupal.org/node/897638
154 | */
155 |
156 | .visuallyhidden.focusable:active,
157 | .visuallyhidden.focusable:focus {
158 | clip: auto;
159 | height: auto;
160 | margin: 0;
161 | overflow: visible;
162 | position: static;
163 | width: auto;
164 | white-space: inherit;
165 | }
166 |
167 | /*
168 | * Hide visually and from screen readers, but maintain layout
169 | */
170 |
171 | .invisible {
172 | visibility: hidden;
173 | }
174 |
175 | /*
176 | * Clearfix: contain floats
177 | *
178 | * For modern browsers
179 | * 1. The space content is one way to avoid an Opera bug when the
180 | * `contenteditable` attribute is included anywhere else in the document.
181 | * Otherwise it causes space to appear at the top and bottom of elements
182 | * that receive the `clearfix` class.
183 | * 2. The use of `table` rather than `block` is only necessary if using
184 | * `:before` to contain the top-margins of child elements.
185 | */
186 |
187 | .clearfix:before,
188 | .clearfix:after {
189 | content: " "; /* 1 */
190 | display: table; /* 2 */
191 | }
192 |
193 | .clearfix:after {
194 | clear: both;
195 | }
196 |
197 | /* ==========================================================================
198 | EXAMPLE Media Queries for Responsive Design.
199 | These examples override the primary ('mobile first') styles.
200 | Modify as content requires.
201 | ========================================================================== */
202 |
203 | @media only screen and (min-width: 35em) {
204 | /* Style adjustments for viewports that meet the condition */
205 | }
206 |
207 | @media print,
208 | (-webkit-min-device-pixel-ratio: 1.25),
209 | (min-resolution: 1.25dppx),
210 | (min-resolution: 120dpi) {
211 | /* Style adjustments for high resolution devices */
212 | }
213 |
214 | /* ==========================================================================
215 | Print styles.
216 | Inlined to avoid the additional HTTP request:
217 | http://www.phpied.com/delay-loading-your-print-css/
218 | ========================================================================== */
219 |
220 | @media print {
221 | *,
222 | *:before,
223 | *:after,
224 | p:first-letter,
225 | div:first-letter,
226 | blockquote:first-letter,
227 | li:first-letter,
228 | p:first-line,
229 | div:first-line,
230 | blockquote:first-line,
231 | li:first-line {
232 | background: transparent !important;
233 | color: #000 !important; /* Black prints faster:
234 | http://www.sanbeiji.com/archives/953 */
235 | box-shadow: none !important;
236 | text-shadow: none !important;
237 | }
238 |
239 | a,
240 | a:visited {
241 | text-decoration: underline;
242 | }
243 |
244 | a[href]:after {
245 | content: " (" attr(href) ")";
246 | }
247 |
248 | abbr[title]:after {
249 | content: " (" attr(title) ")";
250 | }
251 |
252 | /*
253 | * Don't show links that are fragment identifiers,
254 | * or use the `javascript:` pseudo protocol
255 | */
256 |
257 | a[href^="#"]:after,
258 | a[href^="javascript:"]:after {
259 | content: "";
260 | }
261 |
262 | pre {
263 | white-space: pre-wrap !important;
264 | }
265 | pre,
266 | blockquote {
267 | border: 1px solid #999;
268 | page-break-inside: avoid;
269 | }
270 |
271 | /*
272 | * Printing Tables:
273 | * http://css-discuss.incutio.com/wiki/Printing_Tables
274 | */
275 |
276 | thead {
277 | display: table-header-group;
278 | }
279 |
280 | tr,
281 | img {
282 | page-break-inside: avoid;
283 | }
284 |
285 | p,
286 | h2,
287 | h3 {
288 | orphans: 3;
289 | widows: 3;
290 | }
291 |
292 | h2,
293 | h3 {
294 | page-break-after: avoid;
295 | }
296 | }
297 |
--------------------------------------------------------------------------------
/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CrypTools/learn/da480816ba59f93dac637aea68674aafa236cb35/favicon.ico
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CrypTools/learn/da480816ba59f93dac637aea68674aafa236cb35/icon.png
--------------------------------------------------------------------------------
/img/logo-black.svg:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/img/logo-white.svg:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: html
3 | title: CrypTools - Learn
4 | description: The best platform to learn cryptography
5 | ---
6 |
7 |
8 |
9 |
Welcome on our platform to learn cryptography
10 |
11 | Cryptography is the art of writing and solving problems in order to prevent third parties or the public from reading private messages. And as any art, it can be taught. This was our mission by creating this platform. You'll have some challenges to complete,
12 | the first ones are easy, but don't worry, it will get much harder after some point.
13 |
22 |
--------------------------------------------------------------------------------
/noob_questions/b64.md:
--------------------------------------------------------------------------------
1 | # Base64
2 |
3 | # Encoding
4 |
5 | Let's try to encrypt a piece text, for example `"Hello World!"`
6 |
7 | Now, we'll take it's ASCII representation:
8 | ```
9 | 72 101 108 108 111 10 119 111 114 108 100 33
10 | ```
11 | We'll convert that to binary:
12 | ```
13 | 01001000 01100101 01101100 01101100 01101111 00100000 01010111 01101111 01110010 01101100 01100100 00100001
14 | ```
15 | After that, we'll split this 8 bit stream to a 6 bit stream:
16 | ```
17 | 010010 000110 010101 101100 011011 000110 111100 100000 010101 110110 111101 110010 011011 000110 010000 100001
18 | ```
19 | > If your string cannot split up in a 6 bit stream, add padding '0' at the end, we'll replace them by '='
20 |
21 | Now, we'll convert this 6 bit stream to numbers in base 10:
22 | ```
23 | 18 6 21 44 27 6 60 32 21 54 61 50 27 6 16 33
24 | ```
25 | And using the Base64 table:
26 | ```
27 | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
28 | ```
29 | We have:
30 | ```
31 | SGVsbG8gV29ybGQh
32 | ```
33 |
34 | # What you need to do:
35 | - What is the base64 of `CrypTools`?
36 |
--------------------------------------------------------------------------------
/noob_questions/binascii.md:
--------------------------------------------------------------------------------
1 | # Binascii
2 |
3 | # How it works?
4 |
5 | ## Encoding
6 |
7 | ASCII stands for **A**merican **S**tandard **C**ode for **I**nformation **I**nterchange.
8 |
9 | It's a simple way of encoding characters to numbers.
10 |
11 | We can express these characters as hexadecimal (base 16) numbers using this table:
12 |
13 |
14 |
15 |
16 |
0
17 |
NUL
18 |
16
19 |
DLE
20 |
32
21 |
SP
22 |
48
23 |
0
24 |
64
25 |
@
26 |
80
27 |
P
28 |
96
29 |
`
30 |
112
31 |
p
32 |
33 |
34 |
1
35 |
SOH
36 |
17
37 |
DC1
38 |
33
39 |
!
40 |
49
41 |
1
42 |
65
43 |
A
44 |
81
45 |
Q
46 |
97
47 |
a
48 |
113
49 |
q
50 |
51 |
52 |
2
53 |
STX
54 |
18
55 |
DC2
56 |
34
57 |
"
58 |
50
59 |
2
60 |
66
61 |
B
62 |
82
63 |
R
64 |
98
65 |
b
66 |
114
67 |
r
68 |
69 |
70 |
3
71 |
ETX
72 |
19
73 |
DC3
74 |
35
75 |
#
76 |
51
77 |
3
78 |
67
79 |
C
80 |
83
81 |
S
82 |
99
83 |
c
84 |
115
85 |
s
86 |
87 |
88 |
4
89 |
EOT
90 |
20
91 |
DC4
92 |
36
93 |
$
94 |
52
95 |
4
96 |
68
97 |
D
98 |
84
99 |
T
100 |
100
101 |
d
102 |
116
103 |
t
104 |
105 |
106 |
5
107 |
ENQ
108 |
21
109 |
NAK
110 |
37
111 |
%
112 |
53
113 |
5
114 |
69
115 |
E
116 |
85
117 |
U
118 |
101
119 |
e
120 |
117
121 |
u
122 |
123 |
124 |
6
125 |
ACK
126 |
22
127 |
SYN
128 |
38
129 |
&
130 |
54
131 |
6
132 |
70
133 |
F
134 |
86
135 |
V
136 |
102
137 |
f
138 |
118
139 |
v
140 |
141 |
142 |
7
143 |
BEL
144 |
23
145 |
ETB
146 |
39
147 |
'
148 |
55
149 |
7
150 |
71
151 |
G
152 |
87
153 |
W
154 |
103
155 |
g
156 |
119
157 |
w
158 |
159 |
160 |
8
161 |
BS
162 |
24
163 |
CAN
164 |
40
165 |
(
166 |
56
167 |
8
168 |
72
169 |
H
170 |
88
171 |
X
172 |
104
173 |
h
174 |
120
175 |
x
176 |
177 |
178 |
9
179 |
HT
180 |
25
181 |
EM
182 |
41
183 |
)
184 |
57
185 |
9
186 |
73
187 |
I
188 |
89
189 |
Y
190 |
105
191 |
i
192 |
121
193 |
y
194 |
195 |
196 |
10
197 |
LF
198 |
26
199 |
SUB
200 |
42
201 |
*
202 |
58
203 |
:
204 |
74
205 |
J
206 |
90
207 |
Z
208 |
106
209 |
j
210 |
122
211 |
z
212 |
213 |
214 |
11
215 |
VT
216 |
27
217 |
ESC
218 |
43
219 |
+
220 |
59
221 |
;
222 |
75
223 |
K
224 |
91
225 |
[
226 |
107
227 |
k
228 |
123
229 |
{
230 |
231 |
232 |
12
233 |
FF
234 |
28
235 |
FS
236 |
44
237 |
,
238 |
60
239 |
<
240 |
76
241 |
L
242 |
92
243 |
\
244 |
108
245 |
l
246 |
124
247 |
|
248 |
249 |
250 |
13
251 |
CR
252 |
29
253 |
GS
254 |
45
255 |
-
256 |
61
257 |
=
258 |
77
259 |
M
260 |
93
261 |
]
262 |
109
263 |
m
264 |
125
265 |
}
266 |
267 |
268 |
14
269 |
SO
270 |
30
271 |
RS
272 |
46
273 |
.
274 |
62
275 |
>
276 |
78
277 |
N
278 |
94
279 |
^
280 |
110
281 |
n
282 |
126
283 |
~
284 |
285 |
286 |
15
287 |
SI
288 |
31
289 |
US
290 |
47
291 |
/
292 |
63
293 |
?
294 |
79
295 |
O
296 |
95
297 |
_
298 |
111
299 |
o
300 |
127
301 |
DEL
302 |
303 |
304 |
305 |
306 | So we know that `A` correspond to `65` in decimal (base 10).
307 |
308 | ### Convert decimal to Binary
309 | - Take any number `N`.
310 |
311 | - Keep dividing `N` by `2` and write down the remainder (`0` or `1`)
312 | - Reverse the list of remainder
313 |
314 | - Add padding `0`s at the beginning, so for example if we have `101` and we want an 8-bit stream, we output `00000101`.
315 |
316 | # What you need to do?
317 | Write `code` using the Binascii cipher.
318 |
319 | ## Requirements
320 | - Each binary numbers should be expressed in 8 bits
321 | - Separate each characters by a space.
322 |
--------------------------------------------------------------------------------
/noob_questions/bitshift.md:
--------------------------------------------------------------------------------
1 | # BitShift Cipher
2 | > ⚠️ We strongly recommend you to know how to program in at least one programming language.
3 |
4 | ## How it works
5 |
6 | ### Encoding
7 |
8 | The Bitshift Cipher works by (as the name suggests) shifting over the bits of the text's ASCII. We do this using the bitwise `<<` operator, which is used to shift the bits a certain number of places.
9 |
10 | To encode the text, we loop through the text, and for each character `x`, we loop through the key array, and for each key character `i`:
11 |
12 | ```py
13 | x = x + 1 << i % 8
14 | ```
15 |
16 | We limit the maximum shift using modulo to avoid having a bit shifted by hundreds of places
17 |
18 | Example:
19 |
20 | Let's imagine we are currently working on the character `A`, and that our key is `YO`
21 |
22 | ```Python
23 | A = 0b01000001 # ASCII for A
24 | 0b01000010 # plus 1
25 | 0b010000100 # Y is 89, 89 % 8 = 1, so we add 1 zero.
26 | # next charachter in key: O
27 | 0b010000101 # plus 1
28 | 0b0100001010000000 # O is 79, 79 % 8 = 7, so we add 7 zeros.
29 | ```
30 |
31 | After each character is encoded, we add it to an array and reverse the key to make frequency analysis harder.
32 |
33 | Let's say the next character in our string is `B`, our key now is `OY`, as it was reversed.
34 |
35 | ```Python
36 | B = 0b01000010 # ASCII for B
37 | 0b01000011 # plus 1
38 | 0b010000110000000 # O is 79, 79 % 8 = 7, so we add 7 zeros.
39 | # next character in key: Y
40 | 0b010000110000001 # plus 1
41 | 0b0100001100000010 # Y is 89, 89 % 8 = 1, so we add 1 zero.
42 | ```
43 |
44 | Our array now looks like this: `[0b0100001010000000, 0b0100001100000010]`, or in decimal: `[17024, 17154]`.
45 |
46 | Finally, we encode the array in base64 to get the final encrypted string: `'WzE3MDI0LCAxNzE1NF0='`.
47 |
48 | # What you need to do
49 | - What would be, in a decimal array (basically you don't need to Base64 encode your output) the encrypted result of `CrypTools` with the key `learn`.
50 |
51 | ## Requirements
52 | - Your array should begin with `[` and end with `]`.
53 | - No space after or before `[` and `]`
54 | - Separated with a comma and a space like: `, `.
55 | - Integers should be in base 10.
56 | - We'll use unsigned 32 bit integers method to represent numbers.
57 |
--------------------------------------------------------------------------------
/noob_questions/box.md:
--------------------------------------------------------------------------------
1 | # The problem
2 | 
3 |
4 | A magic word is needed to open a certain box. A secret code assign each letter of the alphabet to a unique number. The code for the magic word is written on the outside of he box.
5 |
6 | # What is the word inside the box?
7 | To help you, here is some words that could have been written:
8 | - LOOSER
9 | - SECRET
10 | - LOTTOS
11 | - WINNER
12 |
13 | _This challenge was inspired by [Brilliant](http://brilliant.org)_
14 |
--------------------------------------------------------------------------------
/noob_questions/caesar-encrypt.md:
--------------------------------------------------------------------------------
1 | # Caesar Cipher
2 |
3 | ## History and usage
4 |
5 | The _Caesar Cipher_ was named after Julius Caesar (100 B.C. – 44 B.C). He would use the cipher for secret communication (protect messages of military significance). The Caesar Cipher is a **substitution cipher**. Originally, Julius Caesar would use a shift of three to encrypt/decrypt a message. The Caesar Cipher encrypts a message using an affine function : f(x) = 1x + b.
6 |
7 | ## Detailed Explanations : How it works?
8 |
9 | 1. Firstly, each character of the initial text (message to encrypt) is converted in a number from 0 to 25, corresponding to its position in the Latin alphabet which contains 26 letters --> (a = 0, b = 1 ... z = 25 ).
10 |
11 | 2. Then, each number obtained is transformed by an affine function (f(x) = 1x + b). "x" is representing the number while "b" is defined during the encryption. "b" is the key used to decrypt the final message.
12 |
13 | 3. If we take all the images and put them in a list, we obtain n numbers corresponding to n characters of the initial text. The next step consists in finding the values of modulo 26 of each number. (**Modulo means remainder**)
14 |
15 | > Example : Modulo 4 of 19 is **3** because `19 = 4 * 4 + 3` In the other hand, modulo 26 of 26 is **0** because `26 = 26 * 1 + 0`
16 |
17 | 1. Therefore, we obtain a new list with n element, each between 0 and 25 both included. All these numbers are converted in letters of the Latin Alphabet using the tables below.
18 |
19 | 2. We finally create the final message by putting all the letters side by side.
20 |
21 | Steps 1 and 4 can be done with these tables :
22 |
23 |
24 |
25 |
26 |
A
27 |
B
28 |
C
29 |
D
30 |
E
31 |
F
32 |
G
33 |
H
34 |
I
35 |
J
36 |
K
37 |
L
38 |
M
39 |
N
40 |
O
41 |
P
42 |
Q
43 |
R
44 |
S
45 |
T
46 |
U
47 |
V
48 |
W
49 |
X
50 |
Y
51 |
Z
52 |
53 |
54 |
55 |
56 |
0
57 |
1
58 |
2
59 |
3
60 |
4
61 |
5
62 |
6
63 |
7
64 |
8
65 |
9
66 |
10
67 |
11
68 |
12
69 |
13
70 |
14
71 |
15
72 |
16
73 |
17
74 |
18
75 |
19
76 |
20
77 |
21
78 |
22
79 |
23
80 |
24
81 |
25
82 |
83 |
84 |
85 |
86 | # What you need to do:
87 |
88 | **Using this explanation, what would be the encoded string of `HELLO` with the key `4`**
89 |
--------------------------------------------------------------------------------
/noob_questions/emojigraphy.md:
--------------------------------------------------------------------------------
1 | ## Introduction
2 | This is the first challenge of this platform. It's pretty easy, but don't worry, it will get harder in
3 | the next challenges.
4 |
5 | ### Tutorial:
6 | - On this section, you'll always see the 'course' and the challenge that you need to do
7 | - On your right (or on the bottom if you're on mobile), there is a form. This is where you'll post your answers.
8 | > **ProTip 💡:**
9 | - Press `Enter` to submit your answer.
10 |
11 | # Emoji cipher
12 |
13 | The Emoji cipher is a very basic cipher.
14 |
15 | Basically, we convert letters to emojis to encode a message, and we do the opposite operation to decode this encrypted message.
16 |
17 | Here is the table:
18 |
19 |
20 |
21 |
A
22 |
B
23 |
C
24 |
D
25 |
E
26 |
F
27 |
G
28 |
H
29 |
I
30 |
J
31 |
K
32 |
L
33 |
M
34 |
N
35 |
O
36 |
P
37 |
Q
38 |
R
39 |
S
40 |
T
41 |
U
42 |
V
43 |
W
44 |
X
45 |
Y
46 |
Z
47 |
48 |
49 |
50 |
51 |
😄
52 |
😃
53 |
😀
54 |
😊
55 |
😅
56 |
😉
57 |
😍
58 |
😘
59 |
😚
60 |
😗
61 |
😙
62 |
😜
63 |
😝
64 |
😛
65 |
😳
66 |
😁
67 |
😔
68 |
😌
69 |
😒
70 |
😞
71 |
😣
72 |
😢
73 |
😂
74 |
😭
75 |
😎
76 |
😈
77 |
78 |
79 |
80 |
81 | # What you need to do
82 |
83 | **Using this explanation, what would be the encoded string of `EMOJI`**
84 |
--------------------------------------------------------------------------------
/noob_questions/frequencyanalysis.md:
--------------------------------------------------------------------------------
1 | # Frequency Analysis with Caesar Cipher
2 | Remember the [Caesar Cipher](https://cryptools.github.io/learn/noob#caesar-encrypt) challenge?
3 |
4 | > The Caesar Cipher, also known as a shift cipher, is one of the oldest and simplest forms of encrypting a message. It is a type of substitution cipher where each letter in the original message (which in cryptography is called the plaintext) is replaced with a letter corresponding to a certain number of letters shifted up or down in the alphabet.
5 |
6 | So for example, if our letter is `A` and our shift is `4`, we get `E`.
7 |
8 | # Get the key:
9 | With a given encrypted text, we can get the key by analyzing the letters frequency. For example, in English `E` is the most used letter.
10 |
11 | ### Example
12 | If you have `pixxiv`, we see that there are 2 `i` and 2 `x`. We'll start with `i`, and we'll suppose that it's an `e`.
13 | ```js
14 | i - e = 4 // We aren't substracting letters but their position in the alphabet
15 | ```
16 | Let's try to decode `pixxiv` with `4`.
17 |
18 | And we get `letter`, which is an English word, so the key was `4`.
19 |
20 | # What you need to do?
21 | Try to get the key of the following phrase:
22 | ```
23 | aol xbpjr iyvdu mve qbtwz vcly aol shgf kvn
24 | ```
25 |
--------------------------------------------------------------------------------
/noob_questions/hashshift.md:
--------------------------------------------------------------------------------
1 | # HashShift
2 |
3 | > ⚠️ We strongly recommend you to know how to program in at least one programming language
4 |
5 | ## How it works?
6 |
7 | > We'll use the Swift implementation to describe what we're doing
8 |
9 | First, let's take a seed for our generator:
10 |
11 | ```swift
12 | var seed = 12
13 | ```
14 |
15 | Then let's hash his `String` representation:
16 |
17 | ```swift
18 | let hash = String(seed).sha256
19 | ```
20 |
21 | Now, we'll take the `10` first characters of the outputed hex digest:
22 |
23 | ```swift
24 | let first = hash.prefix(10)
25 | ```
26 |
27 | Now we have a `hex` representation of a number in a `String`, let's parse it:
28 |
29 | ```swift
30 | let n = Int(first, radix: 16)
31 | ```
32 |
33 | Then, we rotate `n` like:
34 |
35 | ```swift
36 | let r = (n! >> 13 * seed) % 99371 // for non-swift developers, 'n!' doesn't mean n factorial but the unwrapped value of n
37 | ```
38 |
39 | And we change the `seed`:
40 |
41 | ```swift
42 | seed = (r ^ n! << 2 + n!) % 70937
43 | ```
44 |
45 | Finally we output the absolute value as `Float` of `r` divided by `99371` to have a number between `0` and `1`:
46 |
47 | ```swift
48 | return Float(abs(r)) / 99371
49 | ```
50 |
51 | # What you need to do?
52 | **Using this explanation, determine what would be the second number outputted using `seed = 12` by the HashShift PRNG**
53 |
54 | ## Requirements
55 | - Your answer is composed of the `10` first digits.
56 | - We write numbers in the english way, like `3.1415926535` or `0.57721566`.
57 |
--------------------------------------------------------------------------------
/noob_questions/inverse.md:
--------------------------------------------------------------------------------
1 | # Question:
2 | If FIND is coded as URMW and ME is coded as NV, then how is CRYPTOOLS coded as?
3 |
4 | ## Help?
5 | You should look at this alphabet table:
6 |
7 |
8 |
9 |
10 |
A
11 |
B
12 |
C
13 |
D
14 |
E
15 |
F
16 |
G
17 |
H
18 |
I
19 |
J
20 |
K
21 |
L
22 |
M
23 |
N
24 |
O
25 |
P
26 |
Q
27 |
R
28 |
S
29 |
T
30 |
U
31 |
V
32 |
W
33 |
X
34 |
Y
35 |
Z
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/noob_questions/railfence.md:
--------------------------------------------------------------------------------
1 | # Railfence Cipher
2 |
3 | A transposition cipher also called the zigzag cipher.
4 |
5 | ## How it works
6 |
7 | ### Encoding
8 |
9 | The Rail Fence Cipher places the letters in a zigzag pattern before reading them again, from top to bottom, right to left, ignoring the zigzag.
10 |
11 | Example:
12 |
13 | Let's imagine that we are encoding `Hello World!` on 3 rails. we draw out our three rails and place the lettres in the zigzag pattern like this:
14 |
15 | ```txt
16 | H - - - o - - - r - - -
17 | - e - l - - o - l - !
18 | - - l - - - w - - - d -
19 | ```
20 |
21 | When this is read top to bottom, left to right, we get `Horel ol!lwd`
22 |
23 | # What you need to do:
24 | - Find what would become the phrase `The Railfence Cipher is not that secure` with `8` rails
25 |
--------------------------------------------------------------------------------
/noob_questions/randomness.md:
--------------------------------------------------------------------------------
1 | # Randomness
2 | > ⚠️ We strongly recommend you to know how to program in at least one programming language.
3 |
4 | You've stumbled onto a significant vulnerability in a commonly used cryptographic library. It turns out that the random number generator it uses frequently produces the same primes when it is generating keys.
5 |
6 | ### Key 1
7 | ```
8 | 1c7bb1ae67670f7e6769b515c174414278e16c27e95b43a789099a1c7d55c717b2f0a0442a7d49503ee09552588ed9bb6eda4af738a02fb31576d78ff72b2499b347e49fef1028182f158182a0ba504902996ea161311fe62b86e6ccb02a9307d932f7fa94cde410619927677f94c571ea39c7f4105fae00415dd7d
9 | ```
10 | ### Key 2
11 | ```
12 | 2710e45014ed7d2550aac9887cc18b6858b978c2409e86f80bad4b59ebcbd90ed18790fc56f53ffabc0e4a021da2e906072404a8b3c5555f64f279a21ebb60655e4d61f4a18be9ad389d8ff05b994bb4c194d8803537ac6cd9f708e0dd12d1857554e41c9cbef98f61c5751b796e5b37d338f5d9b3ec3202b37a32f
13 | ```
14 |
15 | # What you need to do
16 | Exploit this knowledge to factor the (hexadecimal) keys below, and enter your answer as the last six digits of the largest factor you find (in decimal).
17 |
18 |
19 | > This challenge comes from [Brilliant](https://brilliant.org/problems/sometimes-we-need-more-random/)
20 |
--------------------------------------------------------------------------------
/noob_questions/rsa.md:
--------------------------------------------------------------------------------
1 | # RSA
2 | **The RSA encryption is based on the following procedure:**
3 |
4 | Generate two distinct primes p and q.
5 | Compute `n = pq` and `φ = (p - 1)(q - 1)`.
6 | Find an integer `e`, `1 < e < φ`, such that `gcd(e, φ) = 1`.
7 |
8 | A message in this system is a number in the interval `[0, n - 1]`.
9 | A text to be encrypted is then somehow converted to messages (numbers in the interval `[0, n - 1]`).
10 | To encrypt the text, for each message, `m`, `c = me mod n` is calculated.
11 |
12 | To decrypt the text, the following procedure is needed: calculate `d` such that `ed = 1 mod φ`, then for each encrypted message, `c`, calculate `m = cd mod n`.
13 |
14 | There exist values of `e` and `m` such that `me mod n = m`.
15 | We call messages m for which me mod n=m unconcealed messages.
16 |
17 | An issue when choosing e is that there should not be too many unconcealed messages.
18 | For instance, let `p = 19` and `q = 37`.
19 | Then `n= 19*37 = 703` and `φ = 18*36 = 648`.
20 | If we choose `e=181`, then, although `gcd(181, 648) = 1` it turns out that all possible messages
21 | `m (0 ≤ m ≤ n - 1)` are unconcealed when calculating `me mod n`.
22 | For any valid choice of `e` there exist some unconcealed messages.
23 | > It's important that the number of unconcealed messages is at a minimum.
24 |
25 | # What you need to do:
26 | - Choose `p = 1009` and `q = 3643`.
27 |
28 | Find the sum of all values of e, `1< e <φ(1009,3643)` and `gcd(e, φ) = 1`, so that the number of unconcealed messages for this value of `e` is at a minimum.
29 |
--------------------------------------------------------------------------------
/noob_questions/vernam.md:
--------------------------------------------------------------------------------
1 | # Vernam Cipher
2 | Suppose Alice wishes to send the message "HELLO" to Bob. Assume two pads of paper containing identical random sequences of letters were somehow previously produced and securely issued to both. Alice chooses the appropriate unused page from the pad.
3 |
4 | The material on the selected sheet is the key for this message. Each letter from the pad will be combined in a predetermined way with one letter of the message. (It is common, but not required, to assign each letter a numerical value, e.g., "A" is 0, "B" is 1, and so on.)
5 |
6 | # Encryption
7 |
8 | In this example, the technique is to combine the key and the message using modular addition. The numerical values of corresponding message and key letters are added together, modulo 26\. So, if key material begins with "XMCKL" and the message is "HELLO", then the coding would be done as follows:
9 |
10 | ```
11 | H E L L O message
12 | 7 (H) 4 (E) 11 (L) 11 (L) 14 (O) message
13 | + 23 (X) 12 (M) 2 (C) 10 (K) 11 (L) key
14 | = 30 16 13 21 25 message + key
15 | = 4 (E) 16 (Q) 13 (N) 21 (V) 25 (Z) (message + key) mod 26
16 | E Q N V Z → ciphertext
17 | ```
18 |
19 | If a number is larger than 26, then the remainder after subtraction of 26 is taken in modular arithmetic fashion. This simply means that if the computations "go past" Z, the sequence starts again at A.
20 |
21 | # What you need to do?
22 | What would be `CRYPTOOLS` encrypted with `VERNAMCIP`?
23 |
--------------------------------------------------------------------------------
/robots.txt:
--------------------------------------------------------------------------------
1 | # www.robotstxt.org/
2 |
3 | # Allow crawling of all content
4 | User-agent: *
5 | Disallow:
6 |
7 | Sitemap: https://cryptools.github.io/sitemap.txt
8 |
--------------------------------------------------------------------------------