RSAWebPresentation

Begin

you can enter numbers no more than 5 digits

then please click just do it

here you get all the information

such as plain text, two Prime numbers p,q, their product n

the you get public key, private key, the cipher text and plain text

also you can click “watch video” button to watch a relative video,which is also made by us.

here is the address of the web click here to see amazing presentation

here is the repository’s address click here to see the code

here is the vide please click

core code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
function quickpow(m, n, k){
var r = 1;
while(n > 0) {
if(n & 1)
r = (r * m) % k;
n = n >> 1 ;
m = (m * m) % k;
}
return r;
}
// miller-rabin 算法素性检测
function isprime_mr(a,b){
if (!b){
b = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
}
if (a == 2){
return true
}
if (a % 2 == 0 || a == 1){
return false
}
for (var i = 0; i < b.length; i++) {
var x = b[i]
var t = a - 1
while (t % 2 == 0){
var v = quickpow(x, t, a)
if (!(v == 0 ||
v == 1 ||
v == a-1 )){
return false
}else{
if (v == 0 ||
v == a-1){
break
}
t = (t / 2) | 0
}
}
}
return true
}
function gen_prime(bitlen){
var n = (1<<(bitlen-1)) + Math.random() * ((1<<(bitlen-1)) * 0.9) | 1
while (1){
n += 2
if (isprime_mr(n)){
return n
}
}
}
function ex_gcd(a, b){
if (b == 0){
return [1, 0, a]
}
var [x, y, r] = ex_gcd(b, a%b)
var t = x
var x = y
var y = t - (a / b | 0) * y
return [x, y, r]
}
function create_rsa_key(l){
var e = 1861
if (l % 2 == 1){ throw Error('must be even.') }
while(1){
var p = gen_prime(l / 2)
var q = gen_prime(l / 2)
var n = p * q
if ((n.toString(2).length == l) && p != q){
break
}
}
var fn = (p - 1) * (q - 1)
var [a, b, r] = ex_gcd(fn, e)
var d = b < 0 ? b + fn : b
return [e, d, n,p,q]
}

//Function functions are shown in the name