This commit is contained in:
Jakub Adamski 2021-10-07 15:10:41 +02:00
commit 1bb7241fd4
3 changed files with 34 additions and 0 deletions

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# Kryptografia

2
zajecia1/euklides.py Normal file
View File

@ -0,0 +1,2 @@
#rozszerzony algorytm euklidesa

30
zajecia1/potegowanie.py Normal file
View File

@ -0,0 +1,30 @@
#potęgowanie binarne (left-to-right)
def potegowanie(x, k):
y = 1
i = k.bit_length()
while i >= 0:
y = y**2
if (k & 1) == 1:
y = y*x
k = k >> 1
i = i - 1
return y
def potegowanieimod(x, k, n):
y = 1
i = k.bit_length()
while i >= 0:
y = y**2 % n
if (k & 1) == 1:
y = y*x % n
k = k >> 1
i = i - 1
return y
print(potegowanie(2, 6))
print(potegowanieimod(5, 2, 10))