summaryrefslogtreecommitdiff
path: root/pysnmp/proto/secmod/rfc3414/localkey.py
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2019-02-12 23:58:57 +0100
committerGitHub <noreply@github.com>2019-02-12 23:58:57 +0100
commit7a8838eeaf2a94a4ee8d309f2091a4fde13e5afc (patch)
treef6ac400c4897b2076d4e2759e5230e67100357db /pysnmp/proto/secmod/rfc3414/localkey.py
parent2a3fe3b5e08c91ab8d77569b02b36da63909f619 (diff)
downloadpysnmp-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.py17
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()