Skip to content

dmikusa/pc4d-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Practical Cryptography for Developers (in Python)

This repository contains examples of how to use various Python libraries to perform cryptographic operations safely and with purpose.

The primary purposes of cryptography are:

  • Confidentiality
  • Integrity
  • Non-repudiation
  • Authentication

The examples in this repository depend on the libnacl: Python bindings to NaCl packages.

This is inspired by:

See also:

Examples

To run the examples...

  • Install Python 3, preferrably Python 3.7+.
  • Install libsodium. Your package manager can likely do this for you. For example, brew install libsodium or apt install libsodium23.
  • Optional: run python -m venv ./env. This will create a virtual env. Then run ./env/bin/activate to activate the virtual env. This prevents polluting your global Python library.
  • Run pip install -r requirements.txt from the project directory to install dependencies.

You should now be able to run the examples, for example python src/encrypt.py, or try running ./test.sh which runs all four examples and validates they are working correctly.

Confidentiality

Symmetric examples: encrypt.py & decrypt.py

Asymmetric examples: pkencrypt.py & pkdecrypt.py

Run either encrypt.py or pkencrypt.py with the appropriate arguments and the final output should show the command required to decrypt.

Integrity

Hash example: hash.py

Run hash.py with the same input argument and you should get the same output argument every time.

Asymmetric example: pksign.py & pkverify.py

Run pksign.py with the appropriate arguments and the final output should show the command required to verify.

Non-repudiation

Asymmetric examples: pksign.py & pkverify.py

Run pksign.py with the appropriate arguments and the final output should show the command required to verify.

Authentication

Symmetric example: auth.py & verify.py

Run auth.py with the appropriate arguments and the final output should show the command required to verify.

About

Practical Cryptography for Developers (Python)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published