pychickenticket密码工作的快速模块

ct-crypto的Python项目详细描述


forthebadgeforthebadge

mit

pypi

ct_crypto-pychickentiket密码模块

文档

encrypt(data, password)

使用 给定密码,并返回解密数据。

如果使用非默认长度参数解密数据, 加密必须使用相同的参数完成。

  Parameters
  -----------
  data: bytes
    The binary data to encrypt.

  password: str
    The password to encrypt the data with.

  Returns
  --------
  bytes
    Bytes object containing the decrypted data.

  Raises
  -------
  TypeError
    If argument datatypes are incorrect

  ValueError
    If argument length is incorrect

  RuntimeError
    If data decryption authentication fails

  MemoryError
    If key derivation or decryption fails

decrypt(data, password)

使用 给定密码,并返回解密数据。

如果使用非默认长度参数解密数据, 加密必须使用相同的参数完成。

  Parameters
  -----------
  data: bytes
    The binary data to encrypt.

  password: str
    The password to encrypt the data with.

  Returns
  --------
  bytes
    Bytes object containing the decrypted data.

  Raises
  -------
  TypeError
    If argument datatypes are incorrect

  ValueError
    If argument length is incorrect

  RuntimeError
    If data decryption authentication fails

  MemoryError
    If key derivation or decryption fails

get_def(def_index)

获取索引并返回lib钠的值 与该索引关联的常量。

下面的索引->;常量表

  0  ->  crypto_box_SEEDBYTES
  1  ->  crypto_pwhash_SALTBYTES
  2  ->  crypto_pwhash_PASSWD_MIN
  3  ->  crypto_pwhash_PASSWD_MAX
  4  ->  crypto_pwhash_BYTES_MIN
  5  ->  crypto_pwhash_BYTES_MAX
  6  ->  crypto_pwhash_OPSLIMIT_MIN
  7  ->  crypto_pwhash_OPSLIMIT_MAX
  8  ->  crypto_pwhash_MEMLIMIT_MIN
  9  ->  crypto_pwhash_MEMLIMIT_MAX
  10 ->  crypto_secretbox_KEYBYTES
  11 ->  crypto_secretbox_MACBYTES
  12 ->  crypto_secretbox_NONCEBYTES
  13 ->  crypto_secretbox_MESSAGEBYTES_MAX
  Parameters
  -----------
  def_index: int
    Index of the constant you want to fetch.

  Returns
  --------
  int
    Value of the specified constant

  Raises
  -------
  KeyError
    If the index has no associated constant

genkey(key_size)

生成长度为key_size字节的安全密钥。

  Parameters
  -----------
  key_size: int
    Determines the length of the generated key

  Returns
  --------
  bytes
    The generated key

  Raises
  -------
  ValueError
    If key size is below 32

random_bytes(buffer_size)

生成加密安全的随机字节,最多为buffer_size

如果buffer_size为0,则返回None

  Parameters
  -----------
  buffer_size: int
    Determines the size of the buffer used to hold the random bytes.

  Returns
  --------
  bytes
    Buffer of random bytes

hexdigest(data)

返回给定值的hexDigest。

如果data为空,则返回None

  Parameters
  -----------
  data: bytes
    Bytes object to calculate the hexdigest for.

  Returns
  --------
  str
    The hexdigest in string format.

  Raises
  -------
  MemoryError
    If memory could not be allocated for the hex buffer

derive_key(password, salt, key_size)

使用argon2id算法从密码和哈希中派生密钥。 生成的密钥长度为key_size字节。

如果任何参数为空,则返回None

  Parameters
  -----------
  password: str
    Password to use for key derivation.

  salt: bytes
    Bytes object storing the salt to use for key derivation.

  key_size: int
    Determines size of the generated key.

  Returns
  --------
  bytes
    The secret key.

  Raises
  -------
  MemoryError
    If memory could not be allocated for derivation.

encrypt_secret(data, key, nonce)

使用keynonce加密data,使用 用于加密和poly1305的xsalsa20流密码 用于身份验证的Mac。

如果任何参数为空,则返回None

  Parameters
  -----------
  data: bytes
    The data to encrypt.

  key: bytes
    The secret key to use for encryption.

  nonce: bytes
    The nonce to use for encryption.

  Returns
  --------
  bytes
    The encrypted data, signed with the MAC tag.

  Raises
  -------
  MemoryError
    If memory could not be allocated for encryption

  RuntimeError
    If encryption fails

decrypt_secret(data, key, nonce)

使用keynonce解密data,使用 用于加密和poly1305的xsalsa20流密码 用于身份验证的Mac。

如果任何参数为空,则返回None

  Parameters
  -----------
  data: bytes
    The data to decrypt.

  key: bytes
    The secret key to use for decryption.

  nonce: bytes
    The nonce to use for decryption.

  Returns
  --------
  bytes
    The decrypted data.

  Raises
  -------
  MemoryError
    If memory could not be allocated for decryption

  RuntimeError
    If decryption authentication fails

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java分类集转换   java我应该把工作线程放在哪里   桌面上的用户界面图像未显示(Java)   java如何确保输入的输入与数组索引匹配以输出正确的解决方案?   java使用“BasicButtoni”实现相对简单的GUI,这是正确的方法吗?   json调用一个。java类或创建名称与字符串匹配的java类的对象   java我想要我在firebase的键值'pqty'中保存的生产数量的累计值?   java如何在安卓 studio的库模块中使用getResources()函数   java同时关闭服务器和客户端socket连接   从后端提交javascript值时的java星级   java servlet容器和spring容器有什么区别?   从命令行在包中运行java   Selenide中的java捕获shouldHave/shouldBe方法   PostgreSql连接字符串的授权中存在java非法字符   Eclipse中划掉断点的java含义   c#拖放文件上载asp。net还是java   javascript如何使用selenium java处理页面加载时出现的警报框   java为什么这段代码会生成错误:“不可解析的日期”   在OpenGL中生成二维地形的java问题