s1ncipher


Names1ncipher JSON
Version 0.3.1 PyPI version JSON
download
home_page
SummaryA simple cipher keeps original order and can be search partly by encode 1 byte data to many bytes.
upload_time2023-09-09 22:19:58
maintainerJiang Wei
docs_urlNone
authorJiang Wei
requires_python
license
keywords cipherutils s1ncipher
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # s1ncipher

A simple cipher keeps original order and can be search partly by encode 1 byte data to many bytes. 

*Note: s1ncipher designed to be a partly searchable and sortable string encode method, but after many test, we find that it may returns more result while doing partly search. New applications should not use this package anymore. This is kept for old applications that already using this encode method. Use `srndcipher` instead.*

## Install

```shell
pip install s1ncipher
```

## Installed Utils

- s1ncipher_encrypt
- s1ncipher_decrypt
- S1nCipher

## Usage examples

1. Use raw API s1ncipher_encrypt and s1ncipher_decrypt.

```
In [1]: from s1ncipher import s1ncipher_encrypt

In [2]: from s1ncipher import s1ncipher_decrypt

In [3]: password = "test-password"

In [4]: data1 = b"plain text"

In [5]: data2 = s1ncipher_encrypt(data1, password)

In [6]: print(data2)
b's:n\xeceAm\x9eq \xadwX|k\xf6Iy\x0ewX|'

In [7]: data3 = s1ncipher_decrypt(data2, password)

In [8]: print(data3)
b'plain text'

In [9]: data1 == data3
Out[9]: True

In [10]:
```

- Plain data must be in bytes format.
- Encrypted data is also in bytes format.

2. Use S1nCipher enveloped API

```
In [14]: from s1ncipher import S1nCipher

In [15]: from zenutils import cipherutils

In [16]: password = "test-password"

In [17]: text1 = "plain text"

In [18]: cipher = S1nCipher(password=password, result_encoder=cipherutils.HexlifyEncoder(), force_text=True)

In [19]: text2 = cipher.encrypt(text1)

In [20]: print(text2)
733a6eec65416d9e7120ad77587c6bf649790e77587c

In [21]: text3 = cipher.decrypt(text2)

In [22]: print(text3)
plain text

In [23]: text1 == text3
Out[23]: True

```

- Create a cipher instance to do encrypt and decrypt.
- With result_encoder=cipherutils.HexlifyEncoder(), encrypted data will be hexlified.
- With force_text decrypted data will be decoded from bytes to str.

## Test With Python

- 2.7
- 3.2
- 3.3
- 3.4
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9
- 3.10
- 3.11

## Releases

### 0.3.0

- First release.

### 0.3.1

- Deps on zenutils, instead of fastutils.
- Doc fix.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "s1ncipher",
    "maintainer": "Jiang Wei",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "jiangwei@zencore.cn",
    "keywords": "cipherutils,s1ncipher",
    "author": "Jiang Wei",
    "author_email": "jiangwei@zencore.cn",
    "download_url": "https://files.pythonhosted.org/packages/79/08/aabea9a21d3d011979de5f3720d13cada43bc61285e343ac83d4a0cc7528/s1ncipher-0.3.1.tar.gz",
    "platform": null,
    "description": "# s1ncipher\n\nA simple cipher keeps original order and can be search partly by encode 1 byte data to many bytes. \n\n*Note: s1ncipher designed to be a partly searchable and sortable string encode method, but after many test, we find that it may returns more result while doing partly search. New applications should not use this package anymore. This is kept for old applications that already using this encode method. Use `srndcipher` instead.*\n\n## Install\n\n```shell\npip install s1ncipher\n```\n\n## Installed Utils\n\n- s1ncipher_encrypt\n- s1ncipher_decrypt\n- S1nCipher\n\n## Usage examples\n\n1. Use raw API s1ncipher_encrypt and s1ncipher_decrypt.\n\n```\nIn [1]: from s1ncipher import s1ncipher_encrypt\n\nIn [2]: from s1ncipher import s1ncipher_decrypt\n\nIn [3]: password = \"test-password\"\n\nIn [4]: data1 = b\"plain text\"\n\nIn [5]: data2 = s1ncipher_encrypt(data1, password)\n\nIn [6]: print(data2)\nb's:n\\xeceAm\\x9eq \\xadwX|k\\xf6Iy\\x0ewX|'\n\nIn [7]: data3 = s1ncipher_decrypt(data2, password)\n\nIn [8]: print(data3)\nb'plain text'\n\nIn [9]: data1 == data3\nOut[9]: True\n\nIn [10]:\n```\n\n- Plain data must be in bytes format.\n- Encrypted data is also in bytes format.\n\n2. Use S1nCipher enveloped API\n\n```\nIn [14]: from s1ncipher import S1nCipher\n\nIn [15]: from zenutils import cipherutils\n\nIn [16]: password = \"test-password\"\n\nIn [17]: text1 = \"plain text\"\n\nIn [18]: cipher = S1nCipher(password=password, result_encoder=cipherutils.HexlifyEncoder(), force_text=True)\n\nIn [19]: text2 = cipher.encrypt(text1)\n\nIn [20]: print(text2)\n733a6eec65416d9e7120ad77587c6bf649790e77587c\n\nIn [21]: text3 = cipher.decrypt(text2)\n\nIn [22]: print(text3)\nplain text\n\nIn [23]: text1 == text3\nOut[23]: True\n\n```\n\n- Create a cipher instance to do encrypt and decrypt.\n- With result_encoder=cipherutils.HexlifyEncoder(), encrypted data will be hexlified.\n- With force_text decrypted data will be decoded from bytes to str.\n\n## Test With Python\n\n- 2.7\n- 3.2\n- 3.3\n- 3.4\n- 3.5\n- 3.6\n- 3.7\n- 3.8\n- 3.9\n- 3.10\n- 3.11\n\n## Releases\n\n### 0.3.0\n\n- First release.\n\n### 0.3.1\n\n- Deps on zenutils, instead of fastutils.\n- Doc fix.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A simple cipher keeps original order and can be search partly by encode 1 byte data to many bytes.",
    "version": "0.3.1",
    "project_urls": null,
    "split_keywords": [
        "cipherutils",
        "s1ncipher"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d38c14b7e458783e56cbec2c2630fbb2d2142d5e1f4ae620c95d49f92a4259e1",
                "md5": "8eebe483630a5baa17159887c6b08865",
                "sha256": "3a5176306edc4830c12923c3ef98dd7e4bb19fbe187faf5c5327a949601c6e5a"
            },
            "downloads": -1,
            "filename": "s1ncipher-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8eebe483630a5baa17159887c6b08865",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3567,
            "upload_time": "2023-09-09T22:19:56",
            "upload_time_iso_8601": "2023-09-09T22:19:56.426969Z",
            "url": "https://files.pythonhosted.org/packages/d3/8c/14b7e458783e56cbec2c2630fbb2d2142d5e1f4ae620c95d49f92a4259e1/s1ncipher-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7908aabea9a21d3d011979de5f3720d13cada43bc61285e343ac83d4a0cc7528",
                "md5": "c377a42d30c87189ff94c0437d7b29b7",
                "sha256": "fb17c3e63b48fb72325807d6c44302c6e08030ad1eb7ffe37026e4e94aba5f04"
            },
            "downloads": -1,
            "filename": "s1ncipher-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c377a42d30c87189ff94c0437d7b29b7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3828,
            "upload_time": "2023-09-09T22:19:58",
            "upload_time_iso_8601": "2023-09-09T22:19:58.328609Z",
            "url": "https://files.pythonhosted.org/packages/79/08/aabea9a21d3d011979de5f3720d13cada43bc61285e343ac83d4a0cc7528/s1ncipher-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-09 22:19:58",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "s1ncipher"
}
        
Elapsed time: 0.12205s