Skip to content

Commit aeba2c9

Browse files
adds diffie hellman
1 parent b9c38e4 commit aeba2c9

File tree

6 files changed

+30
-27
lines changed

6 files changed

+30
-27
lines changed

diffie-hellman/discrete-log-brute-force.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
b = 7
77
m = 9
88

9-
# table = pandas.DataFrame(discrete_log_table(7))
10-
# print(table)
9+
table = pandas.DataFrame(discrete_log_table(7))
10+
print(table)
1111

12-
print(discrete_log(9, 2, 11))
12+
# print(discrete_log(9, 2, 11))

notebooks/3-symmetric-key-ciphers.ipynb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
{
1414
"cell_type": "code",
15-
"execution_count": 5,
15+
"execution_count": 1,
1616
"metadata": {},
1717
"outputs": [],
1818
"source": [
@@ -22,7 +22,7 @@
2222
},
2323
{
2424
"cell_type": "code",
25-
"execution_count": 6,
25+
"execution_count": 2,
2626
"metadata": {},
2727
"outputs": [
2828
{
@@ -40,7 +40,7 @@
4040
},
4141
{
4242
"cell_type": "code",
43-
"execution_count": 7,
43+
"execution_count": 3,
4444
"metadata": {},
4545
"outputs": [
4646
{
@@ -100,7 +100,7 @@
100100
},
101101
{
102102
"cell_type": "code",
103-
"execution_count": 10,
103+
"execution_count": 4,
104104
"metadata": {},
105105
"outputs": [],
106106
"source": [
@@ -110,7 +110,7 @@
110110
},
111111
{
112112
"cell_type": "code",
113-
"execution_count": 11,
113+
"execution_count": 5,
114114
"metadata": {},
115115
"outputs": [],
116116
"source": [
@@ -147,7 +147,7 @@
147147
},
148148
{
149149
"cell_type": "code",
150-
"execution_count": 12,
150+
"execution_count": 6,
151151
"metadata": {},
152152
"outputs": [
153153
{
@@ -357,7 +357,7 @@
357357
},
358358
{
359359
"cell_type": "code",
360-
"execution_count": 20,
360+
"execution_count": 7,
361361
"metadata": {},
362362
"outputs": [],
363363
"source": [
@@ -426,14 +426,14 @@
426426
},
427427
{
428428
"cell_type": "code",
429-
"execution_count": 21,
429+
"execution_count": 10,
430430
"metadata": {},
431431
"outputs": [
432432
{
433433
"name": "stdout",
434434
"output_type": "stream",
435435
"text": [
436-
"ECGQBX\n"
436+
"NTUBQGBPIZCFOPVEVIVNST\n"
437437
]
438438
}
439439
],
@@ -446,25 +446,25 @@
446446
" ['z', 'y', 'w', 't', 'p']]\n",
447447
")\n",
448448
"\n",
449-
"ciphertext = playfair_cipher.encrypt('hello')\n",
449+
"ciphertext = playfair_cipher.encrypt('iwillattacktomorrow')\n",
450450
"print(ciphertext)"
451451
]
452452
},
453453
{
454454
"cell_type": "code",
455-
"execution_count": 22,
455+
"execution_count": 11,
456456
"metadata": {},
457457
"outputs": [
458458
{
459459
"name": "stdout",
460460
"output_type": "stream",
461461
"text": [
462-
"helmlo\n"
462+
"iwilmlatutacktomorsrow\n"
463463
]
464464
}
465465
],
466466
"source": [
467-
"plaintext = playfair_cipher.decrypt('ECGQBX')\n",
467+
"plaintext = playfair_cipher.decrypt('NTUBQGBPIZCFOPVEVIVNST')\n",
468468
"print(plaintext)"
469469
]
470470
},
@@ -478,7 +478,7 @@
478478
},
479479
{
480480
"cell_type": "code",
481-
"execution_count": 23,
481+
"execution_count": 12,
482482
"metadata": {},
483483
"outputs": [],
484484
"source": [
@@ -506,7 +506,7 @@
506506
},
507507
{
508508
"cell_type": "code",
509-
"execution_count": 24,
509+
"execution_count": 13,
510510
"metadata": {},
511511
"outputs": [
512512
{
@@ -525,7 +525,7 @@
525525
},
526526
{
527527
"cell_type": "code",
528-
"execution_count": 25,
528+
"execution_count": 14,
529529
"metadata": {},
530530
"outputs": [
531531
{
@@ -1198,7 +1198,7 @@
11981198
"name": "python",
11991199
"nbconvert_exporter": "python",
12001200
"pygments_lexer": "ipython3",
1201-
"version": "3.8.3"
1201+
"version": "3.7.9"
12021202
}
12031203
},
12041204
"nbformat": 4,

notebooks/4-mathematics-cryptography-algebraic-structures.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@
374374
"name": "python",
375375
"nbconvert_exporter": "python",
376376
"pygments_lexer": "ipython3",
377-
"version": "3.8.3"
377+
"version": "3.7.9"
378378
}
379379
},
380380
"nbformat": 4,

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
numpy
22
pandas
3+
matplotlib
4+
opencv-python

rsa/rsa_sample.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22
import random
33

44

5-
p, q = 5, 11
5+
p, q = 7, 11
66
n = p * q
77
print('n:', n)
88
phi_n = totient(n)
99
print('totient:', phi_n)
1010
phi_n_list = relatively_prime_numbers(phi_n)
11-
print(phi_n_list)
11+
print('relatively prime numbers to phi(n):', phi_n_list)
1212
# e = phi_n_list[random.randint(0, len(phi_n_list))]
13-
e = 17
13+
e = 13
1414
print('e:', e)
1515
d = multiplicative_inverse(e, phi_n)
1616
print('d:', d)
1717

1818
# m = random.randint(0, n)
1919
m = 8
20-
c = pow(m, e, n)
20+
# c = pow(m, e, n)
21+
c = 20
2122
print('plaintext:', m)
2223
print('ciphertext:', c)
2324

test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
from ciphers.utils import *
44
import numpy as np
55
import math
6-
import tensorflow
76

8-
print(tensorflow.version.VERSION)
7+
8+
print(is_prime(59))

0 commit comments

Comments
 (0)