Skip to main content

Bark encrypted push client

Project description

Encrypted Push Notification Client for Bark / Bark加密推送通知客户端

Features / 特性

  • 支持 AES-128/192/256
  • 支持 加密策略(CBC / ECB,可自定义 GCM 等)

Installation / 安装

pip3 install bark-python

或者

git clone https://github.com/horennel/bark-python.git
python3 setup.py install

Usage / 用法示例

不使用加密
from bark_python import BarkClient

client = BarkClient(device_key="your_device_key", api_url="https://api.day.app")

# 发送推送通知
client.send_notification(
    title="🔒 Secure Title",
    body="Hello from encrypted Bark client!",
    sound="shake",
    # ... 可增加bark支持的参数
)
使用加密
from bark_python import BarkClient, CBCStrategy, ECBStrategy

client = BarkClient(device_key="your_device_key", api_url="https://api.day.app")

# 设置加密方式
client.set_encryption(
    key="1234567890abcdef",  # 默认空,AES128[16位]|AES192[24位]|AES256[32位] 字符串
    iv="abcdef1234567890",  # 默认空,CBC和ECB都为16位字符串
    strategy_cls=CBCStrategy,  # 也可以用 ECBStrategy
)

# 发送推送通知
client.send_notification(
    title="🔒 Secure Title",
    body="Hello from encrypted Bark client!",
    sound="shake"
    # ... 可增加bark支持的参数
)
自定义加密策略
from bark_python import BarkClient, EncryptionStrategy

client = BarkClient(device_key="your_device_key", api_url="https://api.day.app")


# 自定义加密策略
class MyNewStrategy(EncryptionStrategy):
    def encrypt(self, key: str, iv: str, data: str, other_params: dict) -> bytes:
        # 返回加密后的bytes数据
        pass


# 设置加密方式
client.set_encryption(
    strategy_cls=MyNewStrategy,  # 使用自定义加密策略
    other_params={"自定义参数": "自定义参数"}  # 可以添加自定义参数,用于自定义加密策略
)

# 发送推送通知
client.send_notification(
    title="🔒 Secure Title",
    body="Hello from encrypted Bark client!",
    sound="shake"
    # ... 可增加bark支持的参数
)

Credits / 致谢

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bark_python-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

File details

Details for the file bark_python-0.1.0.tar.gz.

File metadata

  • Download URL: bark_python-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for bark_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8d1b37d5ee107d2fc2f27c4b16d4ade92946445742be204327457a38f983a61f
MD5 4eb9c735af0e20782f4a5628a3e1b883
BLAKE2b-256 19e2ac85636ae5a1d5867c9115f03a178f5cc5dbc1c8931098ddd63d7f8bce08

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page