Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ic:labs:01 [2023/10/01 01:15]
razvan.smadu [Hail, Caesar!]
ic:labs:01 [2025/02/23 13:24] (current)
razvan.smadu [Laboratorul 01 - Introducere]
Line 1: Line 1:
 ===== Laboratorul 01 - Introducere ===== ===== Laboratorul 01 - Introducere =====
  
-Puteți lucra acest laborator folosind și platforma Google Colab, accesând [[https://​colab.research.google.com/​drive/1G8ycsy34UwwQqJHp2DgL5MtGERWzkhN_|acest]] link, cu excepția exercițiului bonus. Un scurt tutorial pentru utilizarea platformei poate fi găsit [[https://​docs.google.com/​document/​d/​1Dcnyv9wTfWJx8CEgnR6OgLbHAO7XD1BXGjwOAMAEmlc/​edit|aici]]. ​+Puteți lucra acest laborator folosind și platforma Google Colab, accesând [[https://​colab.research.google.com/​github/ACS-IC-labs/​IC-labs/​blob/​main/​labs/​lab01/​lab1.ipynb|acest]] link, cu excepția exercițiului bonus. Un scurt tutorial pentru utilizarea platformei poate fi găsit [[https://​docs.google.com/​document/​d/​1Dcnyv9wTfWJx8CEgnR6OgLbHAO7XD1BXGjwOAMAEmlc/​edit|aici]]. ​
  
 ==== Python3 Crash Course ==== ==== Python3 Crash Course ====
  
-Tutorialul poate fi găsit [[ic:​resurse:​python|aici]].+Tutorialul poate fi găsit [[ic:​resurse:​python|aici]]. La laboratoare vom folosi Python 3.10 sau mai nou.
  
 ==== Codificare vs Criptare ==== ==== Codificare vs Criptare ====
Line 34: Line 34:
 <file python utils.py>​ <file python utils.py>​
 import base64 import base64
 +from typing import Generator
  
  
Line 43: Line 44:
  
  
-def _chunks(data:​ str, chunk_size: int) -> str:+def _chunks(data:​ str, chunk_size: int) -> Generator[str, None, None]:
     data = _pad(data, chunk_size)     data = _pad(data, chunk_size)
     for i in range(0, len(data), chunk_size):​     for i in range(0, len(data), chunk_size):​
Line 49: Line 50:
  
  
-def _hex(data: ​str) -> str:+def _hex(data: ​int) -> str:
     return format(data,​ "​02x"​)     return format(data,​ "​02x"​)
  
Line 261: Line 262:
     Args:     Args:
         bytes_data (bytearray | bytes): The byte array or the byte string to be         bytes_data (bytearray | bytes): The byte array or the byte string to be
-            converted. It should be encoded in UTF-format.+            converted. It should be encoded in Latin-format.
  
     Returns:     Returns:
         str: The string representation of the byte array or the byte string,         str: The string representation of the byte array or the byte string,
-            decoded using UTF-encoding.+            decoded using Latin-encoding.
  
     Examples:     Examples:
Line 273: Line 274:
         '​IC'​         '​IC'​
     """​     """​
-    return bytes_data.decode(encoding="​utf-8")+    return bytes_data.decode(encoding="​raw_unicode_escape")
  
  
Line 284: Line 285:
     Returns:     Returns:
         bytes: The byte string representation of the string, encoded using         bytes: The byte string representation of the string, encoded using
-        ​UTF-encoding.+        ​Latin-encoding.
  
     Examples:     Examples:
Line 292: Line 293:
         b'​IC'​         b'​IC'​
     """​     """​
-    return string_data.encode(encoding="​utf-8")+    return string_data.encode(encoding="​raw_unicode_escape")
  
  
Line 305: Line 306:
  
     Returns:     Returns:
-        str: The base64 encoded string, using UTF-encoding.+        str: The base64 encoded string, using Latin-encoding.
  
     Examples:     Examples:
Line 324: Line 325:
  
     Returns:     Returns:
-        str: The decoded string, using UTF-encoding.+        str: The decoded string, using Latin-encoding.
  
     Examples:     Examples:
ic/labs/01.1696112110.txt.gz · Last modified: 2023/10/01 01:15 by razvan.smadu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0