Skip to main content

a Python implementation of TripleSec

Project description

Build Status Coverage Status PyPi version PyPi downloads

A Python port of the TripleSec library. See also the JS implementation.

Compatible with Python 2.6, 2.7 and 3.3.

Installation

pip install TripleSec

Usage

Instantiate a triplesec.TripleSec(key=None) object, with or without a key (if omitted it will have to be specified at each use), then use the encrypt(message, key=None) and decrypt(ciphertext, key=None) methods.

All values must be binary strings (str on Python 2, bytes on Python 3)

Shortcuts

The (unkeyed) functions encrypt and decrypt are exposed at the module level.

Command line tool

TripleSec offers a triplesec command line tool to encrypt and decrypt messages from the terminal.

Here is the help:

Command-line TripleSec encryption-decryption tool

usage: triplesec [-h] [-b | --hex] [-k KEY] {enc|dec} [data]

positional arguments:
  {enc|dec}          enc: encrypt and sign a message with TripleSec; by
                     default output a hex encoded ciphertext (see -b and
                     --hex) -- dec: decrypt and verify a TripleSec ciphertext
  data               the TripleSec message or ciphertext; if not specified it
                     will be read from stdin; by default ciphertexts will be
                     considered hex encoded (see -b and --hex)

optional arguments:
  -h, --help         show this help message and exit
  -b, --binary       consider all input (key, plaintext, ciphertext) to be
                     plain binary data and output everything as binary data -
                     this turns off smart decoding/encoding - if you pipe
                     data, you should use this
  --hex              consider all input (key, plaintext, ciphertext) to be hex
                     encoded; hex encode all output
  -k KEY, --key KEY  the TripleSec key; if not specified will check the
                     TRIPLESEC_KEY env variable, then prompt the user for it

API

Sphinx documentation coming soon.

Example

>>> import triplesec
>>> x = triplesec.encrypt(b"IT'S A YELLOW SUBMARINE", b'* password *')
>>> print(triplesec.decrypt(x, b'* password *').decode())
IT'S A YELLOW SUBMARINE
>>> from triplesec import TripleSec
>>> T = TripleSec(b'* password *')
>>> x = T.encrypt(b"IT'S A YELLOW SUBMARINE")
>>> print(T.decrypt(x).decode())
IT'S A YELLOW SUBMARINE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TripleSec-0.4.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

TripleSec-0.4-py3.7.egg (22.9 kB view details)

Uploaded Source

File details

Details for the file TripleSec-0.4.tar.gz.

File metadata

  • Download URL: TripleSec-0.4.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for TripleSec-0.4.tar.gz
Algorithm Hash digest
SHA256 f1c2eb898f492b33073718557cc72997973299f07d06743856df490d562fd1b0
MD5 598ea49743ff567b57cef376929bba02
BLAKE2b-256 c5d5e40811e51a3262b12e4c02551deb0c8699b172e42439c656f64926178c35

See more details on using hashes here.

File details

Details for the file TripleSec-0.4-py3.7.egg.

File metadata

  • Download URL: TripleSec-0.4-py3.7.egg
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for TripleSec-0.4-py3.7.egg
Algorithm Hash digest
SHA256 0b091e827f4f47fe63fb805959e4cc67d58b71573d84ecebf2d503e747892b92
MD5 9298739d3e98f153284f67512ebc8b83
BLAKE2b-256 9ebd09a52a7b79816a3d328b607d70a50068cfa9b27ace19ab8f843970c982bf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page