semvec/pypi-packages huggingface dataset:
xycrypto 0.9
A friendly cryptographic primitives library.
License: MIT
Requires Python: >=3.6

# xycrypto

## Installation

Require Python 3.6+.

```shell
pip install -U xycrypto
```

## Ciphers

The `xycrypto` provides simple and elegant interfaces for ciphers.

The cryptography components for ciphers we support:
- Available *stream cipher*: `ChaCha20`, `RC4`.
- Available *block cipher*: `AES`, `Blowfish`, `Camellia`, `CAST5`, `DES`, `IDEA`, `SEED`, `TripleDES`.
- Available *mode*: `ECB`, `CBC`, `CFB`, `OFB`, `CTR`.
- Available *padding*: `PKCS7`, `ANSIX923`, `ISO10126`.

### Usage

**Firstly**, you should import the cipher class from the package `xycrypto.ciphers`. The cipher class follows the following naming conventions:
- For *stream cipher*, `<cipher_name>`.
- For *block cipher*, `<cipher_name>_<mode>`.

```python
>>> from xycrypto.ciphers import AES_CBC
```

**Secondly**, you should create the instance of the cipher class. In this case, you should provide some arguments:
- *key* for all ciphers.
- *iv* for *block cipher* in `ECB`, `CBC`, `OFB`, `CFB` mode.
- *nonce* for *block cipher* in `CTR` mode.
- *padding* for *block cipher* in `ECB`, `CBC` mode.

```python
# The len(key) is 16 bytes for AES-128, you can use 32 bytes key for AES-256.
>>> key = b'0123456789abcdef'
# Note len(iv) should be equal to AES_CBC.block_size.
>>> iv = b'0123456789abcdef'
# We use PKCS7 padding.
>>> cipher = AES_CBC(key, iv=iv, padding='PKCS7')
```

**Finally**, call `encrypt` or `decrypt` method to encrypt or decrypt data respectively.

```python
>>> plaintext = b'Welcome to xycrypto!'
>>> ciphertext = cipher.encrypt(plaintext) 
>>> ciphertext
b'3\x0f\xad\xa6\x17\xc4}\xb9\t\x17\xf8\xae\xbb\xa2t\xb9o\xf2\xf6\x16\t\x0803\xaci\x0c\x19q\x9d\xa3O'
>>> cipher.decrypt(ciphertext)
b'Welcome to xycrypto!'
```

### Example

```python
>>> from xycrypto.ciphers import AES_CBC

# The len(key) is 16 bytes for AES-128, you can use 32 bytes key for AES-256.
>>> key = b'0123456789abcdef'
# Note len(iv) should be equal to AES_CBC.block_size.
>>> iv = b'0123456789abcdef'
# We use PKCS7 padding.
>>> cipher = AES_CBC(key, iv=iv, padding='PKCS7')

>>> plaintext = b'Welcome to xycrypto!'
>>> ciphertext = cipher.encrypt(plaintext) 
>>> ciphertext
b'3\x0f\xad\xa6\x17\xc4}\xb9\t\x17\xf8\xae\xbb\xa2t\xb9o\xf2\xf6\x16\t\x0803\xaci\x0c\x19q\x9d\xa3O'
>>> cipher.decrypt(ciphertext)
b'Welcome to xycrypto!'
```
bqunit 0.1.3
Testing framework for BigQuery SQL
License: MIT
Requires Python: >=3.7,<4.0
Keywords: BigQuery,sql,test

BQUnit
==========

Testing framework for BigQuery SQL.

What is this?
-------------

BigQuery enables us to execute "super-fast SQL queries
using the processing power of Google's infrastructure".

However, testing query-based data pipelines sometimes become depressing work, because:

* SQL itself takes more responsibility in data transformation logic,
  and the glue code layer like Python scripts(which is relatively easy to test) doesn't.
* We can't imitate BigQuery infrastructure easily.
  There's no Docker image, StandardSQL has many unique syntaxes which can't be used on other RDBMS,
  and above all, Google has huge computing resources than ours.

BQUnit solves this problem, by managing your test data preparation
on your BigQuery data set, which is isolated from your production environment.


Usage
------------

First, instantiate BQUnit object::

    bqunit = BQUnit(project_id='test-env-123456', dataset_name='bqunit')

    # If Application Default Credential is set, project id is not required.
    bqunit = BQUnit(dataset_name='bqunit')

And then, mockup your tables by a fixture() method call::

    bqunit.fixture(
        table_name='your-production-123456.foo.bar',
        statement="""
        select 1 as col1, 'str_1' as col2, true as col3
        union all
        select 2, 'str_2', false
        """)

**You don't need to know where to insert your test data**.
You just need to specify your production table name here.

Testing will be like this::

    tested_query = """
       select col1, col2
       from `your-production-123456.foo.bar` foo
       where col1 = 1
     """
    query_result = bqunit.test_query(tested_query)
    assert query_result.total_rows == 1

BQUnit execute your query on test data set, which is created when you called the fixture() method,
so you can predict its result set correctly, and make assertions.

Note that *query_result* will be RowIterator object of *google-cloud-bigquery* library.
see also `google-cloud-bigquery documentation
<https://googleapis.dev/python/bigquery/latest/generated/google.cloud.bigquery.table.RowIterator.html>`_.