diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-02-12 23:58:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-12 23:58:57 +0100 |
commit | 7a8838eeaf2a94a4ee8d309f2091a4fde13e5afc (patch) | |
tree | f6ac400c4897b2076d4e2759e5230e67100357db /pysnmp/proto/secmod/rfc3414/localkey.py | |
parent | 2a3fe3b5e08c91ab8d77569b02b36da63909f619 (diff) | |
download | pysnmp-git-7a8838eeaf2a94a4ee8d309f2091a4fde13e5afc.tar.gz |
PEP8 optimize imports (#242)
To make them PEP8-compliant
Diffstat (limited to 'pysnmp/proto/secmod/rfc3414/localkey.py')
-rw-r--r-- | pysnmp/proto/secmod/rfc3414/localkey.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/pysnmp/proto/secmod/rfc3414/localkey.py b/pysnmp/proto/secmod/rfc3414/localkey.py index 651722e4..144342fa 100644 --- a/pysnmp/proto/secmod/rfc3414/localkey.py +++ b/pysnmp/proto/secmod/rfc3414/localkey.py @@ -4,39 +4,34 @@ # Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> # License: http://snmplabs.com/pysnmp/license.html # -try: - from hashlib import md5, sha1 - -except ImportError: - import md5 - import sha - - md5 = md5.new - sha1 = sha.new +from hashlib import md5 +from hashlib import sha1 from pyasn1.type import univ def hashPassphrase(passphrase, hashFunc): passphrase = univ.OctetString(passphrase).asOctets() - # noinspection PyDeprecation,PyCallingNonCallable hasher = hashFunc() ringBuffer = passphrase * (64 // len(passphrase) + 1) - # noinspection PyTypeChecker ringBufferLen = len(ringBuffer) count = 0 mark = 0 + while count < 16384: e = mark + 64 if e < ringBufferLen: hasher.update(ringBuffer[mark:e]) mark = e + else: hasher.update( ringBuffer[mark:ringBufferLen] + ringBuffer[0:e - ringBufferLen] ) mark = e - ringBufferLen + count += 1 + return hasher.digest() |