Skip to content

Commit 1957f21

Browse files
committed
add PEP8 formatting in camellia/__init__.py
1 parent d7f890a commit 1957f21

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/camellia/__init__.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,19 @@
3232

3333

3434
if sys.version_info.major <= 2:
35-
b = lambda b: "".join(map(chr, b))
35+
def b(b):
36+
return "".join(map(chr, b))
3637
else:
3738
b = bytes
3839

40+
3941
def Camellia_Ekeygen(rawKey):
4042
"""
4143
Make a keytable from a key.
4244
4345
:param rawKey: raw encryption key, 16, 24 or 32 bytes long
4446
:type rawKey: bytestring
45-
47+
4648
:returns: `CFFI <https://cffi.readthedocs.io/en/latest/>`_ array
4749
"""
4850
keyLength = len(rawKey)*8
@@ -58,6 +60,7 @@ def Camellia_Ekeygen(rawKey):
5860

5961
return keytable
6062

63+
6164
def Camellia_Encrypt(keyLength, keytable, plainText):
6265
r"""Encrypt a plaintext block by given arguments."""
6366
if keyLength not in [128, 192, 256]:
@@ -73,7 +76,7 @@ def Camellia_Encrypt(keyLength, keytable, plainText):
7376
lib.Camellia_EncryptBlock(keyLength, inp, keytable, out)
7477

7578
return b(out)[:-1]
76-
79+
7780

7881
def Camellia_Decrypt(keyLength, keytable, cipherText):
7982
r"""Decrypt a plaintext block by given arguments."""
@@ -94,7 +97,7 @@ def Camellia_Decrypt(keyLength, keytable, cipherText):
9497

9598
def new(key, mode, **kwargs):
9699
"""Create an "CamelliaCipher" object.
97-
100+
98101
:param key: The key for encrytion/decryption. Must be 16/24/32 in length.
99102
:type key: bytestring
100103
@@ -112,14 +115,16 @@ def new(key, mode, **kwargs):
112115
"""
113116
return CamelliaCipher(key, mode, **kwargs)
114117

118+
115119
key_size = None
116120
block_size = 16
117121

122+
118123
class CamelliaCipher(PEP272Cipher):
119124
"""The CamelliaCipher object."""
120125

121126
#: block size of the camellia cipher
122-
block_size = 16
127+
block_size = 16
123128

124129
def __init__(self, key, mode, **kwargs):
125130
"""Constructer of Cipher class. See :func:`camellia.new`."""
@@ -148,7 +153,7 @@ def test(v=True):
148153
c = CamelliaCipher(binascii.unhexlify(key), mode=MODE_ECB)
149154

150155
ec = c.encrypt(binascii.unhexlify(plain))
151-
156+
152157
if not ec == binascii.unhexlify(cipher):
153158
if v:
154159
print("Result:\t\tcipher=%s" % binascii.hexlify(ec).decode())

0 commit comments

Comments
 (0)