Skip to content

Commit 039da39

Browse files
committed
Make for the counters slightly more concise
1 parent 0d0bc3a commit 039da39

1 file changed

Lines changed: 5 additions & 17 deletions

File tree

hkdf.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,18 @@
33
import hmac
44
import hashlib
55
import sys
6-
from struct import pack, error as struct_error
6+
from struct import Struct, pack, error as struct_error
77
from itertools import count, islice
88

99
if sys.version_info[0] == 3:
1010
buffer = lambda x: x
1111

1212

1313
MAX_INT64 = 0xffffffffffffffffffffffffffffffff
14-
15-
16-
def COUNTER8(x):
17-
return pack('>B', x)
18-
19-
20-
def COUNTER16(x):
21-
return pack('>H', x)
22-
23-
24-
def COUNTER32(x):
25-
return pack('>I', x)
26-
27-
28-
def COUNTER64(x):
29-
return pack('>Q', x)
14+
COUNTER8 = Struct('>B').pack
15+
COUNTER16 = Struct('>H').pack
16+
COUNTER32 = Struct('>I').pack
17+
COUNTER64 = Struct('>Q').pack
3018

3119

3220
def COUNTER128(x):

0 commit comments

Comments
 (0)