def potegowanie_modulo(a, b, n): wynik = 1 a = a % n if a == 0: return 0 while b > 0: if (b % 2 == 1): wynik = wynik * a % n b //= 2 a = (a * a) % n return wynik def odszyfruj(c, klucz_prywatny): return potegowanie_modulo(c, klucz_prywatny[0], klucz_prywatny[1]) def odszyfruj_string(szyfrogram, klucz_prywatny): tekst = "" for i in range(len(szyfrogram)): ch = ord(szyfrogram[i]) - 32 ch = odszyfruj(ch, klucz_prywatny) ch += 32 tekst += chr(ch) return tekst klucz_prywatny = (65, 95) szyfrogram = "ZRst- d*.z^ -7t Ltde m7 de^Rd*-." tekst = odszyfruj_string(szyfrogram, klucz_prywatny) print(tekst)