semvec/pypi-packages huggingface dataset:
pyope 0.2.2
Implementation of symmetric order-preserving encryption scheme
License: MIT

pyope
=====

|PyPi version| |Travis build|

This is an implementation of Boldyreva symmetric `order-preserving encryption`_ scheme (`Boldyreva's paper`_).

Supported Python versions: 2.7 and 3.4+

**Disclaimer 1** This is an experimental implementation, which should be thoroughly reviewed and evaluated before using in production and/or sensitive applications.

**Disclaimer 2** The Boldyreva scheme is not a standardized algorithm, so there are no test vectors and fixed plaintext-ciphertext
mapping for a given key. It means that, generally speaking, a plaintext encrypted with the same key by two different versions of the package might not be equal to each other.

Quick examples
--------------

Quick start

.. code:: python

  from pyope.ope import OPE
  random_key = OPE.generate_key()
  cipher = OPE(random_key)
  assert cipher.encrypt(1000) < cipher.encrypt(2000) < cipher.encrypt(3000)
  assert cipher.decrypt(cipher.encrypt(1337)) == 1337


You can specify input and output ranges. Otherwise, default input (0..2^15-1) and output (0..2^31-1) ranges are used.

.. code:: python

  from pyope.ope import OPE, ValueRange
  cipher = OPE(b'long key' * 2, in_range=ValueRange(-100, 100),
                                out_range=ValueRange(0, 9999))
  assert 0 < cipher.encrypt(10) < cipher.encrypt(42) < 9999


About order-preserving encryption
---------------------------------

Order-preserving encryption (OPE) allows to compare ciphertext values in order to learn the corresponding relation
between the underlying plaintexts. By definition, order-preserving encryption methods are **less secure** than
conventional encryption algorithms for the same data sizes, because the former leak ordering information of the plaintext 
values.

How can OPE be useful? For example, some systems may need OPE to perform a certain set of queries (such as range SQL
queries) over encrypted data. These systems include `CryptDB`_ and `Monomi`_ to name a few.

Security
--------

As mentioned above, security guarantees for Boldyreva's schema are weaker than those of deterministic encryption schemes,
but security can still be improved if the encryption keys are long enough. It is advised to use randomly generated keys at
least 256 bits long.


Running tests
-------------

PyTest is used as a test framework. Run all tests:

::

$ py.test tests/

TODO
----

- More tests
- Optimize performance
- Security guarantees?

.. |PyPi version| image:: https://img.shields.io/pypi/v/pyope.svg
   :target: https://pypi.python.org/pypi/pyope/
.. |Travis build| image:: https://travis-ci.org/tonyo/pyope.svg?branch=master
   :target: https://travis-ci.org/tonyo/pyope/
.. _order-preserving encryption: https://crypto.stackexchange.com/questions/3813/how-does-order-preserving-encryption-work
.. _Boldyreva's paper: http://www.cc.gatech.edu/~aboldyre/papers/bclo.pdf
.. _CryptDB: http://css.csail.mit.edu/cryptdb/
.. _Monomi: http://people.csail.mit.edu/nickolai/papers/tu-monomi.pdf



=======
History
=======

0.1.0 (2017-01-01)
------------------

* Use 'cryptography' instead of 'pycrypto'
jdb2 0.2.2
A memory-level non-relational database
License: MIT
Keywords: jsondb memdb db

![apm](https://img.shields.io/apm/l/vim-mode.svg?style=plastic)
#### 介绍
`jsonDB2`是一个基于内存的键值对数据库(非关系型数据库)

#### 安装
```bash
$ pip install jdb2
```
或者
```bash
$ git clone https://github.com/spdir/jsonDB2.git
$ cd jsonDB2
$ python setup.py install
```

#### 使用

1. 初始化实例
```python
import jdb2
#初始化一个空的DB
n = jdb2.NoSql()
#将原来的数据导入到数据库,并配置自动持久化
n = jdb2.NoSql(dump=True, nosqlFile='filePath', dumpTime=10)
  # dump: 启动持久化,并导入已有数据, 默认: False
  # nosqlFile: 持久化文件路径
  # dumpTime: 持久化时间间隔(单位: 秒), 默认: 30
#创建一个数据库, 如果数据库存在此库，则返回存在库的对象
d1 = n.createDB('d1')
```
2. 操作使用
```python
>>> import jdb2
>>> n = jdb2.NoSql()   #初始化实例对象
>>> d1 = n.createDB('d1') #创建一个DB
>>> t1 = d1.createTable('t1') #创建一张表
>>> d1.setValue('a','b')  #db设置一个参数
>>> d1.getValue('a')  #db获取一个参数
'b'
>>> t1.setValue(1,2)  #tb设置一个参数
>>> t1.getValue(1)  #tb获取一个参数
2
>>> d1.getValues()  #获取所有的value
[{1: 2}, 'b']
>>> d1.getKeys()  #获取所有的key
['t1', 'a']
>>> d1.getItems() #获取所有的键值对, 返回list
[('t1', {1: 2}), ('a', 'b')]
>>> d1.dropKey('a') #删除一个键或者一张表
>>> d1.setValue('c','d')
>>> d1.clearKey('c')  #清除一个key的内容
>>> d1.getItems()
[('t1', {1: 2}), ('c', None)]
>>> d1.clearKey('t1') #清除一张表的内容
>>> d1.getItems()
[('t1', {}), ('c', None)]
>>> t1.lenTable() #获取数据库或表长度
1
>>> d1.allData()  #获取所有的表或库的所有键值对，返回dict
{'t1': {}, 'c': None}
```
diay 0.1.3
diay - a dependency injection library
License: MIT
Keywords: dependency injection,inversion of control

# Diay - a dependency injection library

[![Build Status](https://travis-ci.org/anlutro/diay.py.svg?branch=master)](https://travis-ci.org/anlutro/diay.py)
[![Latest version on PyPI](https://img.shields.io/pypi/v/diay.svg?maxAge=2592000)](https://pypi.org/project/diay)
[![Licence](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

Diay is a [dependency injection](https://en.wikipedia.org/wiki/Dependency_injection)/[inversion of control](https://en.wikipedia.org/wiki/Inversion_of_control) library for Python 3.5 and higher. It leverages the type hints introduced in 3.5 to allow you to easily call functions or construct classes that require specific types of objects to function.

As an extremely basic and somewhat contrived example - the value of the library doesn't really come into play until you have fairly deeply nested dependencies - let's say you want to render a jinja2 template using some data from an API.

```python
injector = diay.Injector()
injector.set_instance(SomeConfigClass, my_config_object)

@injector.provider
def make_jinja_environment() -> jinja2.Environment:
    return jinja2.Environment()

@injector.provider
def make_api_client(config: SomeConfigClass) -> some.APIclient:
    return some.APIclient(config.api_token)

def render(j2env: jinja2.Environment, apiclient: some.APIclient):
    data = apiclient.get('/some/data')
    template = j2env.get_template('some-template.html.j2', data=data)
    return template.render()

html = injector.call(render)
```