X-Git-Url: https://www.wagner.pp.ru/gitweb/?a=blobdiff_plain;f=ctypescrypto%2Fcipher.py;h=ff614783a77f965680f84018c48850f93a16ad88;hb=ff669c32aa77c9ebfb9c5371b2c8a9d41de614f8;hp=815a42541897232853a0721b9fea12be9d42217b;hpb=ca6a5055ad8a9ea82e9f42aff3c906903d5e6df7;p=oss%2Fctypescrypto.git diff --git a/ctypescrypto/cipher.py b/ctypescrypto/cipher.py index 815a425..ff61478 100644 --- a/ctypescrypto/cipher.py +++ b/ctypescrypto/cipher.py @@ -117,10 +117,7 @@ class Cipher: if self.ctx == 0: raise CipherError("Unable to create cipher context") self.encrypt = encrypt - if encrypt: - enc = 1 - else: - enc = 0 + enc=1 if encrypt else 0 if not iv is None and len(iv) != cipher_type.iv_length(): raise ValueError("Invalid IV length for this algorithm") @@ -151,10 +148,7 @@ class Cipher: """ Sets padding mode of the cipher """ - if padding: - padding_flag = 1 - else: - padding_flag = 0 + padding_flag=1 if padding else 0 libcrypto.EVP_CIPHER_CTX_set_padding(self.ctx, padding_flag) def update(self, data): @@ -173,7 +167,7 @@ class Cipher: raise CipherError("No updates allowed") if not isinstance(data,str): raise TypeError("A string is expected") - if len(data) <= 0: + if len(data) == 0: return "" outbuf=create_string_buffer(self.block_size+len(data)) outlen=c_int(0)