|
1 | 1 | # eciespy |
2 | 2 |
|
3 | 3 | [](https://app.codacy.com/gh/ecies/py/dashboard) |
| 4 | +[](https://github.com/ecies/py) |
| 5 | +[](https://pypi.org/project/eciespy/) |
| 6 | +[](https://pypistats.org/packages/eciespy) |
| 7 | +[](https://pypi.org/project/eciespy/) |
4 | 8 | [](https://github.com/ecies/py/actions) |
5 | 9 | [](https://codecov.io/gh/ecies/py) |
6 | | -[](https://pypi.org/project/eciespy/) |
7 | | -[](https://pypi.org/project/eciespy/) |
8 | | -[](https://github.com/ecies/py) |
9 | 10 |
|
10 | 11 | Elliptic Curve Integrated Encryption Scheme for secp256k1 in Python. |
11 | 12 |
|
12 | 13 | Other language versions: |
13 | 14 |
|
14 | | -- [Rust](https://github.com/ecies/rs) |
15 | 15 | - [TypeScript](https://github.com/ecies/js) |
| 16 | +- [Rust](https://github.com/ecies/rs) |
16 | 17 | - [Golang](https://github.com/ecies/go) |
17 | 18 | - [WASM](https://github.com/ecies/rs-wasm) |
| 19 | +- [Java](https://github.com/ecies/java) |
| 20 | +- [Dart](https://github.com/ecies/dart) |
18 | 21 |
|
19 | | -You can also check a FastAPI web backend demo [here](https://github.com/ecies/py-demo). |
| 22 | +You can also check a web backend demo [here](https://github.com/ecies/py-demo). |
20 | 23 |
|
21 | 24 | ## Install |
22 | 25 |
|
23 | 26 | `pip install eciespy` |
24 | 27 |
|
| 28 | +Or `pip install 'eciespy[eth]'` to use `ecies.utils.generate_eth_key`. |
| 29 | + |
25 | 30 | ## Quick Start |
26 | 31 |
|
27 | 32 | ```python |
28 | | ->>> from ecies.utils import generate_eth_key, generate_key |
| 33 | +>>> from ecies.utils import generate_key |
29 | 34 | >>> from ecies import encrypt, decrypt |
30 | | ->>> eth_k = generate_eth_key() |
31 | | ->>> sk_hex = eth_k.to_hex() # hex string |
32 | | ->>> pk_hex = eth_k.public_key.to_hex() # hex string |
33 | | ->>> data = b'this is a test' |
34 | | ->>> decrypt(sk_hex, encrypt(pk_hex, data)) |
35 | | -b'this is a test' |
36 | | ->>> secp_k = generate_key() |
37 | | ->>> sk_bytes = secp_k.secret # bytes |
38 | | ->>> pk_bytes = secp_k.public_key.format(True) # bytes |
39 | | ->>> decrypt(sk_bytes, encrypt(pk_bytes, data)) |
40 | | -b'this is a test' |
| 35 | +>>> data = 'hello world🌍'.encode() |
| 36 | +>>> sk = generate_key() |
| 37 | +>>> sk_bytes = sk.secret # bytes |
| 38 | +>>> pk_bytes = sk.public_key.format(True) # bytes |
| 39 | +>>> decrypt(sk_bytes, encrypt(pk_bytes, data)).decode() |
| 40 | +'hello world🌍' |
41 | 41 | ``` |
42 | 42 |
|
43 | 43 | Or just use a builtin command `eciespy` in your favorite [command line](#command-line-interface). |
44 | 44 |
|
45 | 45 | ## API |
46 | 46 |
|
47 | | -### `ecies.encrypt(receiver_pk: Union[str, bytes], msg: bytes) -> bytes` |
| 47 | +### `ecies.encrypt(receiver_pk: Union[str, bytes], data: bytes, config: Config = ECIES_CONFIG) -> bytes` |
48 | 48 |
|
49 | 49 | Parameters: |
50 | 50 |
|
51 | 51 | - **receiver_pk** - Receiver's public key (hex str or bytes) |
52 | | -- **msg** - Data to encrypt |
| 52 | +- **data** - Data to encrypt |
| 53 | +- **config** - Optional configuration object |
53 | 54 |
|
54 | 55 | Returns: **bytes** |
55 | 56 |
|
56 | | -### `ecies.decrypt(receiver_sk: Union[str, bytes], msg: bytes) -> bytes` |
| 57 | +### `ecies.decrypt(receiver_sk: Union[str, bytes], data: bytes, config: Config = ECIES_CONFIG) -> bytes` |
57 | 58 |
|
58 | 59 | Parameters: |
59 | 60 |
|
60 | 61 | - **receiver_sk** - Receiver's private key (hex str or bytes) |
61 | | -- **msg** - Data to decrypt |
| 62 | +- **data** - Data to decrypt |
| 63 | +- **config** - Optional configuration object |
62 | 64 |
|
63 | 65 | Returns: **bytes** |
64 | 66 |
|
|
0 commit comments