This shows you the differences between two versions of the page.
ic:labs:03 [2023/10/01 23:17] razvan.smadu [Exercițiul 1 (3p)] |
ic:labs:03 [2023/10/16 20:53] (current) razvan.smadu |
||
---|---|---|---|
Line 1: | Line 1: | ||
===== Laboratorul 03 - PRGs ===== | ===== Laboratorul 03 - PRGs ===== | ||
- | Prezentarea PowerPoint pentru acest laborator poate fi găsită [[https://drive.google.com/file/d/1IfyMkfV6jQDzW5KhS_B6wt_azV31SLjL/view?usp=sharing|aici]]. | + | Prezentarea PowerPoint pentru acest laborator poate fi găsită [[https://drive.google.com/file/d/1IfyMkfV6jQDzW5KhS_B6wt_azV31SLjL/view?usp=sharing|aici]]. Puteți găsi o scurtă prezentare a noțiunii de avantaje în [[https://drive.google.com/file/d/1F_mtKi0zeAn1xYQs6Wc7IiiVX8ZW6aeG/view?usp=sharing|acest]] PDF. |
- | Puteți lucra acest laborator folosind și platforma Google Colab, accesând [[https://colab.research.google.com/drive/1dT6VieWJ1QeMLkb0UY3bAuKvTnkRmWBq?usp=sharing | + | Puteți lucra acest laborator folosind platforma Google Colab, accesând [[https://colab.research.google.com/github/ACS-IC-labs/IC-labs/blob/main/labs/lab03/lab3.ipynb |
|acest]] link. | |acest]] link. | ||
+ | <hidden> | ||
<spoiler Click pentru a vedea utils.py> | <spoiler Click pentru a vedea utils.py> | ||
<file python utils.py> | <file python utils.py> | ||
Line 336: | Line 337: | ||
Puteți folosi următorul schelet de cod: | Puteți folosi următorul schelet de cod: | ||
<code python 'ex1_weak_rng.py'> | <code python 'ex1_weak_rng.py'> | ||
+ | from typing import List, Tuple | ||
+ | |||
from utils import * | from utils import * | ||
Line 398: | Line 401: | ||
# TODO 4: Print the full plaintext | # TODO 4: Print the full plaintext | ||
- | p = "" | + | p = ... |
print("Full plaintext is:", p) | print("Full plaintext is:", p) | ||
Line 489: | Line 492: | ||
import random | import random | ||
- | def get_random_string(n): | + | def get_random_string(n: int) -> str: |
- | """ Generate random bit string """ | + | """Generate random bit string""" |
- | return bin(random.getrandbits(n)).lstrip('0b').zfill(n) | + | return bin(random.getrandbits(n)).lstrip("0b").zfill(n) |
</code> | </code> | ||
</note> | </note> | ||
Line 501: | Line 504: | ||
</note> | </note> | ||
+ | <file python ex4.py> | ||
+ | import math | ||
+ | import random | ||
+ | |||
+ | from utils import * | ||
+ | |||
+ | |||
+ | def get_random_string(n: int) -> str: | ||
+ | """Generate random bit string""" | ||
+ | return bin(random.getrandbits(n)).lstrip("0b").zfill(n) | ||
+ | |||
+ | |||
+ | def main() -> None: | ||
+ | N_RUNS = 100 # the number of runs | ||
+ | N_BITS = 1000 # the number of bits to generate | ||
+ | |||
+ | # TODO: implement and run the multiple times (e.g., 100) the | ||
+ | # statistical tests | ||
+ | |||
+ | |||
+ | if __name__ == "__main__": | ||
+ | main() | ||
+ | </file> | ||
==== Exercițiul 5 - Bonus (2p) ==== | ==== Exercițiul 5 - Bonus (2p) ==== | ||
Line 520: | Line 546: | ||
Încercați să implementați aceeași funcționalitate folosind OpenSSL. OpenSSL suportă RC4, dar nu și Salsa20. Folosiți ChaCha20 in loc de Salsa20, aceasta fiind o variantă îmbunătățită a algoritmului. | Încercați să implementați aceeași funcționalitate folosind OpenSSL. OpenSSL suportă RC4, dar nu și Salsa20. Folosiți ChaCha20 in loc de Salsa20, aceasta fiind o variantă îmbunătățită a algoritmului. | ||
+ | |||
+ | </hidden> |