ucryptolib – cryptographic ciphers ucryptolib – 加密密码 ==========================================

Classes 类 ——-

class aes
classmethod __init__(key, mode[, IV])

Initialize cipher object, suitable for encryption/decryption. Note: after initialization, cipher object can be use only either for encryption or decryption. Running decrypt() operation after encrypt() or vice versa is not supported. 初始化密码对象,适合加密/解密。注意: 初始化后,cipher对象只能用于 加密或解密。在加密()后运行解密()操作 反之亦然。

Parameters are: 参数:

  • key is an encryption/decryption key (bytes-like).

  • key 是一个加密/解密密钥(类似字节)。

  • mode is:

    • 1 (or ucryptolib.MODE_ECB if it exists) for Electronic Code Book (ECB).

    • 2 (or ucryptolib.MODE_CBC if it exists) for Cipher Block Chaining (CBC).

    • 6 (or ucryptolib.MODE_CTR if it exists) for Counter mode (CTR).

  • IV is an initialization vector for CBC mode.

  • IV 是CBC模式的初始化向量。

  • For Counter mode, IV is the initial value for the counter.

*为计数器模式,*IV*为计数器的初始值。

encrypt(in_buf[, out_buf])

Encrypt in_buf. If no out_buf is given result is returned as a newly allocated bytes object. Otherwise, result is written into mutable buffer out_buf. in_buf and out_buf can also refer to the same mutable buffer, in which case data is encrypted in-place. 加密* in_buf 。如果没有给出*out_buf,则返回结果 新分配的`bytes`对象。否则,结果被写入 可变的缓冲* out_buf **in_buf*和*out_buf*也可以引用 到相同的可变缓冲区,在这种情况下,数据被就地加密。

decrypt(in_buf[, out_buf])

Like encrypt(), but for decryption. 类似于`encrypt()`,但用于解密。