background preloader

Crypto

Facebook Twitter

Python gnupg (GPG) example. Python gnupg (GPG) example python-gnupg is a Python package for encrypting and decrypting strings or files using GNU Privacy Guard (GnuPG or GPG).

Python gnupg (GPG) example

GPG is an open source alternative to Pretty Good Privacy (PGP). A popular use of GPG and PGP is encrypting email. For more information, see the python-gnupg documentation. Another option for encrypting data from Python is keyczar. Install¶ This installs the Ubuntu GPG package, creates a test user, and installs the Python package, python-gnupg. . $ sudo apt-get install gnupg $ sudo adduser testgpguser $ sudo su testgpguser $ cd $ virtualenv --no-site-packages venv $ source venv/bin/activate $ pip install python-gnupg Generate a key¶ This creates a GPG key. . $ sudo apt-get install rng-tools import osimport gnupg os.system('rm -rf /home/testgpguser/gpghome')gpg = gnupg.GPG(gnupghome='/home/testgpguser/gpghome')input_data = gpg.gen_key_input( name_email='testgpguser@mydomain.com', passphrase='my passphrase')key = gpg.gen_key(input_data)print key.

Ericson-cepeda/PySSSS. Secret sharing scheme using python? That's a very open-ended question.

Secret sharing scheme using python?

You'll have a much better chance of getting an answer if you can narrow it down. What part of the problem don't you understand? Are you having trouble writing the code to generate the partial secrets, or writing the code to recover the secret from some number of partials, or are you stuck on the basic concept, or what?

Do you understand how to fit a curve (specifically a curve defined by a polynomial) to a given set of points? Do you understand simultaneous equations and how to solve them? If you're having trouble with code then show us the piece that's not behaving, tell us what you expect it to do, and tell us what actually happens when you run the code. > Am having details with the concept of secret sharing in general. OK, let's see if I can explain that. If your secret isn't already a number, start by converting it into one. Constructing the equation is straightforward.

A + Bx +Cx^2 + Dx^3 +Ex^4 + ... = y. Hash Functions and its Importance. From time to time, servers and databases are stolen or compromised.

Hash Functions and its Importance

With this in mind, it is important to ensure that some crucial user data, such as passwords, can not be recovered. Today, we are going to learn the basics behind hashing and what it takes to protect passwords in your web applications. Disclaimer Cryptology is a sufficiently complicated subject, and I am by no means an expert. AES encryption in Python with M2Crypto.

I’ve needed to write some Python code to handle encryption and decryption recently.

AES encryption in Python with M2Crypto

This is a short post describing how I did it. I’m interacting with a system which encrypts data in transit like so: The encryption algorithm is AES with a 16 bit [sic] key. The cipher mode is CBC with PKCS5 padding. The initialisation vector is 16 bytes of 00. PKCS#5 PBKDF2 for Python. This module implements the password-based key derivation function, PBKDF2, specified in RSA PKCS#5 v2.0.

PKCS#5 PBKDF2 for Python

Quick start Install from PyPI: pip install pbkdf2 Example PBKDF2 usage. AES256 with PKCS5 padding. Encryption using pycrypto, AES, and PKCS5 padding. AES encryption of files in Python with PyCrypto. [Updated 15.11.2013: passing IV is required in the new PyCrypto] The PyCrypto module seems to provide all one needs for employing strong cryptography in a program.

AES encryption of files in Python with PyCrypto

It wraps a highly optimized C implementation of many popular encryption algorithms with a Python interface. PyCrypto can be built from source on Linux, and Windows binaries for various versions of Python 2.x were kindly made available by Michael Foord on this page. My only gripe with PyCrypto is its documentation. The auto-generated API doc is next to useless, and this overview is somewhat dated and didn't address the questions I had about the module. In this article I want to present how to use PyCrypto for simple symmetric encryption and decryption of files using the AES algorithm.

Simple AES encryption Here's how one can encrypt a string with AES: Since the PyCrypto block-level encryption API is very low-level, it expects your key to be either 16, 24 or 32 bytes long (for AES-128, AES-196 and AES-256, respectively). Decryption.