m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/25/a.lua
blob: f2505653c865f1c4da798dd86af6dba713ce80f6 (plain)
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
card_pkey = 8421034
door_pkey = 15993936
modulus = 20201227

function step(value, subject)
    return (value * subject) % modulus
end

function reverse(pkey, subject)
    value = 1
    steps = 0
    while value ~= pkey do
        value = step(value, subject)
        steps = steps + 1
    end

    return steps
end

function transform(subject, loop)
    value = 1
    for i = 1, loop do
        value = step(value, subject)
    end

    return value
end

card_steps = reverse(card_pkey, 7)

encryption_key = transform(door_pkey, card_steps)

print(encryption_key)