Freedom of Cryptography

Today I learned that if you could travel back to the early 1990s with the contents of this git repository, you would have had to become a licensed arms dealer 😮 —the govt certainly would have denied you an export license— before you could post the source code (or any work that featured the source code) on the internet.

Publicly sharing the following code snippet would have landed you in prison for arms trafficking because export of cryptography from the United States was regulated at the same level as missiles, tanks, etc…😮.

In [1]: from cryptography.fernet import Fernet

In [2]: key = Fernet.generate_key()

In [3]: f = Fernet(key)

In [4]: plain_text = b'Hello Alice'

In [5]: cipher_text = f.encrypt(plain_text)

In [6]: cipher_text
Out[6]: b'gAAAAABgMjSru96WoOLHq3ygBw93ZICzyu5aKjYQqw0MQ7G44Ch77-xqCVNmYSbB4j6Kz_Ipol3hyPWx5Ti5rui1SdRc_D7LfA=='

In [7]: f.decrypt(cipher_text)
Out[7]: b'Hello Alice'

Resources with more deailed history of the legal battles for freedom of cryptography: