semvec/pypi-packages huggingface dataset:
hybrid-cipher 0.1.1
Hybrid Encryption Mode with Public-Key Encryption and Symmetric Encryption.
License: MIT
Keywords: hybrid-cipher

# hybrid-cipher

Hybrid Encryption Mode with Public-Key Encryption and Symmetric Encryption.

## Install

```
pip install hybrid-cipher
```

## 加密原理

### 加密步骤

1. 生成随机32位临时密钥。
2. 使用RSA公钥加密临时密钥。
3. 使用临时密钥及AES GCM加密算法加密数据内容。
4. 把临时密钥的密文及数据密文相关字段拼接在一起，作为整体密文。

### 解密步骤

1. 分割密文为：临时密钥密文、数据密文相关字段。
2. 使用RSA私钥解密临时密钥密文，得到临时密钥明文。
3. 使用临时密钥明文及AES GCM解密算法解密数据密文相关字段，得到数据明文。

## Usage

```
In [1]: from Crypto.PublicKey import RSA
   ...: from hybrid_cipher import HybridCipher
   ...: 
   ...: sk = RSA.generate(1024)

In [2]: 

In [2]: cipher = HybridCipher(sk)

In [3]: cipher.encrypt({"a": "b"})
Out[3]: 'LS8T8hzgCfzo9QzlJ8pO7DD+pSolam9EZIhr35gTSGQayTj2NLqPgx7T8VGbgC2EnAf7fuFN0EXNlljQt1Vg9EyUC8sAMCRCw21zGN/SQttVQFQrETtZndNw/c5pODMVeVFELKnzbw0E50IC3f4mTd38il6O7fQz9SH7zr8Lle0=.tXn5E6vUHLbufPi7gIEFJg+iZDrxOq73q3ds3ZUHFOA=.51hM5vLf4x3nmwlbKRTgwA==.DK5W89RZ9MCl220YqZo5mA==./0O4k+4zIwIGrw=='

In [4]: cipher.decrypt('LS8T8hzgCfzo9QzlJ8pO7DD+pSolam9EZIhr35gTSGQayTj2NLqPgx7T8VGbgC2EnAf7fuFN0EXNlljQt1Vg9EyUC8sAMCRCw21zGN/SQttVQFQrETtZndNw/c5pODMVeVFELKnzbw0E50IC3f4mTd
   ...: 38il6O7fQz9SH7zr8Lle0=.tXn5E6vUHLbufPi7gIEFJg+iZDrxOq73q3ds3ZUHFOA=.51hM5vLf4x3nmwlbKRTgwA==.DK5W89RZ9MCl220YqZo5mA==./0O4k+4zIwIGrw==')
Out[4]: {'a': 'b'}
```

## Release

### v0.1.1

- First release.
karp-lex-types 0.7.3
The types of karp-lex
License: MIT
Requires Python: >=3.10

# karp-lex-types

[![PyPI version](https://badge.fury.io/py/karp-lex-types.svg)](https://pypi.org/project/karp-lex-types/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/karp-lex-types)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/karp-lex-types)](https://pypi.org/project/karp-lex-types/)

[![Maturity badge - level 3](https://img.shields.io/badge/Maturity-Level%203%20--%20Stable-green.svg)](https://github.com/spraakbanken/getting-started/blob/main/scorecard.md)
[![Stage](https://img.shields.io/pypi/status/sparv-sbx-word-prediction-kb-bert)](https://pypi.org/project/sparv-sbx-word-prediction-kb-bert/)

[![Code Coverage](https://codecov.io/gh/spraakbanken/karp-lex-types/branch/main/graph/badge.svg)](https://codecov.io/gh/spraakbanken/karp-lex-types/)

[![CI(check)](https://github.com/spraakbanken/karp-lex-types/actions/workflows/check.yml/badge.svg)](https://github.com/spraakbanken/karp-lex-types/actions/workflows/check.yml)
[![CI(release)](https://github.com/spraakbanken/karp-lex-types/actions/workflows/release.yml/badge.svg)](https://github.com/spraakbanken/karp-lex-types/actions/workflows/release.yml)
[![CI(scheduled)](https://github.com/spraakbanken/karp-lex-types/actions/workflows/scheduled.yml/badge.svg)](https://github.com/spraakbanken/karp-lex-types/actions/workflows/scheduled.yml)
[![CI(test)](https://github.com/spraakbanken/karp-lex-types/actions/workflows/test.yml/badge.svg)](https://github.com/spraakbanken/karp-lex-types/actions/workflows/test.yml)

Types for karp-lex. Mainly [`pydantic`](https://docs.pydantic.dev/latest/)-types for easy validation and export of models.

Contains commands, entry_dto and unique_id used in [`karp-backend`](https://github.com/spraakbanken/karp-backend).

Can be used for defining resource models in python that pydantic validates, perfect when creating Karp resources.