• Tekshirdi: Mardiyev Ulug’bek Toshkent 2023 5 –VARIANT
  • Guruh talabasi Keldiyorov Mansur ning Kriptografiya fanidan




    Download 345,56 Kb.
    Sana06.12.2023
    Hajmi345,56 Kb.
    #112805
    Bog'liq
    Kriptografiya4 mansur


    O’ZBEKISTON RESPUBLIKASI RAQAMLI TEXNOLOGIYALARI VAZIRLIGI
    Muhammad al-Xorazmiy nomidagi Toshkent axborot texnologiyalari universiteti



    Kiberxavfsizlik fakulteti III bosqich CRY001- guruh talabasi Keldiyorov Mansur ning
    Kriptografiya fanidan
    4-amaliy ishi
    Bajardi:Keldiyorov Mansur
    Tekshirdi: Mardiyev Ulug’bek

    Toshkent 2023
    5 –VARIANT

    N=5678910111213141516171819
    import random
    def power(a, n, p):
    res = 1
    a = a % p
    while n > 0:
    if n & 1:
    res = (res * a) % p
    n = n >> 1
    a = (a * a) % p
    return res
    def fermat_test(n, k):
    if n <= 1:
    return False
    if n == 2:
    return True
    for _ in range(k):
    a = random.randint(2, n - 1)
    if power(a, n - 1, n) != 1:
    return False
    return True
    number = 5678910111213141516171819
    iterations = 5
    if fermat_test(number, iterations):
    print("Berilgan son tub son.")
    else:
    print("Berilgan son tub son emas.")
    import random
    def power(a, n, p):
    res = 1
    a = a % p
    while n > 0:
    if n & 1:
    res = (res * a) % p
    n = n >> 1
    a = (a * a) % p
    return res
    def jacobi(a, n):
    if n <= 0 or n % 2 == 0:
    raise ValueError("n must be a positive odd integer.")
    if a == 0:
    return 0
    if a == 1:
    return 1
    result = 1
    while a != 0:
    while a % 2 == 0:
    a //= 2
    if n % 8 == 3 or n % 8 == 5:
    result = -result
    a, n = n, a
    if a % 4 == 3 and n % 4 == 3:
    result = -result
    a %= n
    if n == 1:
    return result
    return 0
    def solovay_strassen_test(n, k):
    if n <= 1:
    return False
    if n == 2 or n == 3:
    return True
    for _ in range(k):
    a = random.randint(2, n - 2)
    x = power(a, (n - 1) // 2, n)
    if x != 1 and x != n - 1:
    return False
    jacobi_val = jacobi(a, n)
    if x % n != jacobi_val % n:
    return False
    return True
    number_str = "5678910111213141516171819"
    number = int(number_str)
    iterations = 5
    if solovay_strassen_test(number, iterations):
    print("Berilgan son tub son.")
    else:
    print("Berilgan son tub son emas.")

    1-rasm. n 25 xonalik son
    Endi 100 xonalik son uchun dasturda tekshiramiz:
    N=56789101112131415161718192021222324252627282 930313233343536373839404142434445464748495051523

    2-rasm. n 100 xonalik son
    Download 345,56 Kb.




    Download 345,56 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Guruh talabasi Keldiyorov Mansur ning Kriptografiya fanidan

    Download 345,56 Kb.