public_key_cryptography course - challenges 1 and 2 - pow and basic encryption

This commit is contained in:
boyreau 2026-11-05 12:08:15 +01:00
commit 410a1b7cac
2 changed files with 18 additions and 1 deletions

View file

@ -8,9 +8,13 @@ from intro import (
mystery_xor,
mystery_key,
)
from public_key_cryptography import (
modular_exponentiation,
basic_encryption,
)
if __name__ == "__main__":
# Intro-level challenge
# Intro-level challenges
# fmt: off
print(int_to_ascii([99, 114, 121, 112, 116, 111, 123, 65, 83, 67, 73, 73, 95, 112, 114, 49, 110, 116, 52, 98, 108, 51, 125]))
print(hex_to_ascii("63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d"))
@ -25,3 +29,8 @@ if __name__ == "__main__":
print(mystery_xor(0x73626960647f6b206821204f21254f7d694f7624662065622127234f726927756d))
print(mystery_key(0x0e0b213f26041e480b26217f27342e175d0e070a3c5b103e2526217f27342e175d0e077e263451150104))
# fmt: on
# fmt: off
# Public-key cryptography course challenges
print(modular_exponentiation())
print(basic_encryption(12, 17, 23))
# fmt: on

View file

@ -0,0 +1,8 @@
# Challenge PK-crypto-1
def modular_exponentiation():
return pow(101, 17, 22663)
# Challenge PK-crypto-2
def basic_encryption(message: int, p: int, q: int):
return pow(message, 0x10001, p * q)