Differences

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

Link to this comparison view

ic:laboratoare:05 [2020/11/03 17:13]
acosmin.maria
ic:laboratoare:05 [2020/11/04 14:00] (current)
philip.dumitru [Exercise 3 (5p)]
Line 58: Line 58:
 def string_to_bytes(string_data):​ def string_to_bytes(string_data):​
     return string_data.encode() ​ # default utf-8     return string_data.encode() ​ # default utf-8
 +    ​
 +# THIS ONE IS NEW
 +def hex_2_bytes(hex_data):​
 +    return bytes.fromhex(hex_data) ​ # default utf-8
 </​file>​ </​file>​
  
Line 82: Line 86:
 === A. Install the pycrypto library === === A. Install the pycrypto library ===
  
-See https://​pypi.python.org/​pypi/​pycrypto.+<​hidden>​this is outdated: ​https://​pypi.python.org/​pypi/​pycrypto.</​hidden>​ 
 +See https://​pypi.org/​project/​pycryptodome/​ 
  
 === B. Implement 2DES === === B. Implement 2DES ===
Line 181: Line 187:
         The bytestring ciphertext c         The bytestring ciphertext c
     """​     """​
-    d = DES.new(k)+    d = DES.new(k, DES.MODE_ECB)
     c = d.encrypt(m)     c = d.encrypt(m)
     return c     return c
Line 201: Line 207:
         The bytestring plaintext m         The bytestring plaintext m
     """​     """​
-    d = DES.new(k)+    d = DES.new(k, DES.MODE_ECB)
     m = d.decrypt(c)     m = d.decrypt(c)
     return m     return m
ic/laboratoare/05.1604416404.txt.gz · Last modified: 2020/11/03 17:13 by acosmin.maria
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