https://github.com/virgilsecurity/virgil-crypto-python
Virgil Python Crypto Library is a high-level cryptographic library that allows you to perform all necessary operations for secure storing and transferring data and everything required to become HIPAA and GDPR compliant.
https://github.com/virgilsecurity/virgil-crypto-python
crypto cryptography e2ee encryption end-to-end-encryption gdpr hipaa
Last synced: 5 months ago
JSON representation
Virgil Python Crypto Library is a high-level cryptographic library that allows you to perform all necessary operations for secure storing and transferring data and everything required to become HIPAA and GDPR compliant.
- Host: GitHub
- URL: https://github.com/virgilsecurity/virgil-crypto-python
- Owner: VirgilSecurity
- License: bsd-3-clause
- Created: 2016-10-27T12:44:47.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-05-08T10:56:07.000Z (over 5 years ago)
- Last Synced: 2025-04-20T10:41:43.274Z (6 months ago)
- Topics: crypto, cryptography, e2ee, encryption, end-to-end-encryption, gdpr, hipaa
- Language: Python
- Homepage: https://developer.virgilsecurity.com/docs/how-to#cryptography
- Size: 6.64 MB
- Stars: 9
- Watchers: 7
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Virgil Crypto Library Python
[](https://travis-ci.com/VirgilSecurity/virgil-crypto-python) [](https://pypi.python.org/pypi/virgil-crypto) [](https://pypi.python.org/pypi/virgil-crypto) [](https://pypi.python.org/pypi/virgil-crypto)
[Introduction](#introduction) | [Library purposes](#library-purposes) | [Installation](#installation) | [Usage examples](#usage-examples) | [Docs](#docs) | [License](#license) | [Contacts](#support)
## Introduction
Virgil Crypto Library Python is a wrapper over [Virgil Crypto Library C](https://github.com/VirgilSecurity/virgil-crypto-c). It provides a bunch of custom hybrid algorithms that combine different crypto algorithms to solve common complex cryptographic problems in an easy way. That eliminates the requirement for developers to have strong cryptographic skills in order to add a security layer to their applications.
## Library purposes
* Asymmetric Key Generation
* Encryption/Decryption of data and streams
* Generation/Verification of digital signatures
* Double Ratchet algorithm support
* **Post-quantum algorithms support**: [Round5](https://round5.org/) (encryption) and [Falcon](https://falcon-sign.info/) (signature)
* Crypto for using [Virgil Core SDK](https://github.com/VirgilSecurity/virgil-sdk-python)## Installation
### Installing prerequisites
Install latest pip distribution: download [get-pip.py](https://bootstrap.pypa.io/get-pip.py) and run it using the python interpreter.
### Installing from wheel binary packages
We provide binary packages for all the supported platforms.
Use pip to install the wheel binary packages:```bash
pip install virgil-crypto
```## Usage examples
### Generate a key pair
Generate a private key using the default algorithm (EC_X25519):
```python
from virgil_crypto import VirgilCryptocrypto = VirgilCrypto()
key_pair = crypto.generate_key_pair()
```### Generate and verify a signature
Generate signature and sign data with a private key:
```python
from virgil_crypto import VirgilCryptocrypto = VirgilCrypto()
key_pair = crypto.generate_key_pair()
sender_private_key = key_pair.private_keymessage_to_sign = "Hello, Bob!"
data_to_sign = message_to_sign.encode()signature = crypto.generate_signature(data_to_sign, sender_private_key)
```Verify a signature with a public key:
```python
from virgil_crypto import VirgilCryptocrypto = VirgilCrypto()
verified = crypto.verify_signature(data_to_sign, signature, sender_public_key)
```### Encrypt and decrypt data
Encrypt data with a public key:
```python
from virgil_crypto import VirgilCryptocrypto = VirgilCrypto()
message_to_encrypt = "Hello, Bob!"
data_to_encrypt = message_to_encrypt.encode()reciver_list = [reciver_public_key]
encrypted_data = crypto.encrypt(data_to_encrypt, *reciver_list)
```Decrypt the encrypted data with a private key:
```python
from virgil_crypto import VirgilCryptocrypto = VirgilCrypto()
decrypted_data = crypto.decrypt(encrypted_data, reciver_private_key)
decrypted_message = bytes(decrypted_data).decode()
```### Import and export keys
Export keys:
```
crypto = VirgilCrypto()# generate a Key Pair
key_pair = crypto.generate_keys()# export a Private key
private_key_data = crypto.export_private_key(key_pair.private_key, "[YOUR_PASSWORD]")
base64.b64encode(private_key_data)# export a Public key
public_key_data = crypto.export_public_key(key_pair.public_key, "[YOUR_PASSWORD]")
base64.b64encode(public_key_data)
```Import keys:
```
crypto = VirgilCrypto()
private_key_str = "MIGhMF0GCSqGSIb3DQEFDTBQMC8GCSqGSIb3DQEFDDAiBBBtfBoM7VfmWPlvyHuGWvMSAgIZ6zAKBggqhkiG9w0CCjAdBglghkgBZQMEASoEECwaKJKWFNn3OMVoUXEcmqcEQMZ+WWkmPqzwzJXGFrgS/+bEbr2DvreVgEUiLKrggmXL9ZKugPKG0VhNY0omnCNXDzkXi5dCFp25RLqbbSYsCyw="
private_key_data = base64.b64decode(private_key_str)# import a Private key
crypto.import_private_key(private_key_data, "[YOUR_PASSWORD]")//-----------------------------------------------------
crypto = VirgilCrypto()
public_key_str = "MCowBQYDK2VwAyEA9IVUzsQENtRVzhzraTiEZZy7YLq5LDQOXGQG/q0t0kE="
public_key_data = base64.b64decode(public_key_str)# import a Public key
crypto.import_public_key(public_key_data)
```## Docs
- [API Reference](http://virgilsecurity.github.io/virgil-crypto-python/)
- [Crypto Core Library](https://github.com/VirgilSecurity/virgil-crypto)
- [Developer Documentation](https://developer.virgilsecurity.com/docs/)## License
This library is released under the [3-clause BSD License](LICENSE).## Support
Our developer support team is here to help you. Find out more information on our [Help Center](https://help.virgilsecurity.com/).You can find us on [Twitter](https://twitter.com/VirgilSecurity) or send us email support@VirgilSecurity.com.
Also, get extra help from our support team on [Slack](https://virgilsecurity.com/join-community).