Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
1ccdff90
Kaydet (Commit)
1ccdff90
authored
Kas 02, 2001
tarafından
Andrew M. Kuchling
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[Patch #477336] Make hmac.py match PEP247, and fix the copy method() so that
it works
üst
a0b6035a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
23 deletions
+13
-23
hmac.py
Lib/hmac.py
+13
-23
No files found.
Lib/hmac.py
Dosyayı görüntüle @
1ccdff90
...
...
@@ -10,10 +10,14 @@ def _strxor(s1, s2):
"""
return
""
.
join
(
map
(
lambda
x
,
y
:
chr
(
ord
(
x
)
^
ord
(
y
)),
s1
,
s2
))
# The size of the digests returned by HMAC depends on the underlying
# hashing module used.
digest_size
=
None
class
HMAC
:
"""RFC2104 HMAC class.
This
(mostly)
supports the API for Cryptographic Hash Functions (PEP 247).
This supports the API for Cryptographic Hash Functions (PEP 247).
"""
def
__init__
(
self
,
key
,
msg
=
None
,
digestmod
=
None
):
...
...
@@ -27,9 +31,11 @@ class HMAC:
import
md5
digestmod
=
md5
self
.
digestmod
=
digestmod
self
.
outer
=
digestmod
.
new
()
self
.
inner
=
digestmod
.
new
()
self
.
digest_size
=
digestmod
.
digest_size
blocksize
=
64
ipad
=
"
\x36
"
*
blocksize
opad
=
"
\x5C
"
*
blocksize
...
...
@@ -56,7 +62,11 @@ class HMAC:
An update to this copy won't affect the original object.
"""
return
HMAC
(
self
)
other
=
HMAC
(
""
)
other
.
digestmod
=
self
.
digestmod
other
.
inner
=
self
.
inner
.
copy
()
other
.
outer
=
self
.
outer
.
copy
()
return
other
def
digest
(
self
):
"""Return the hash value of this hashing object.
...
...
@@ -88,23 +98,3 @@ def new(key, msg = None, digestmod = None):
"""
return
HMAC
(
key
,
msg
,
digestmod
)
def
test
():
def
md5test
(
key
,
data
,
digest
):
h
=
HMAC
(
key
,
data
)
assert
(
h
.
hexdigest
()
.
upper
()
==
digest
.
upper
())
# Test vectors from the RFC
md5test
(
chr
(
0x0b
)
*
16
,
"Hi There"
,
"9294727A3638BB1C13F48EF8158BFC9D"
)
md5test
(
"Jefe"
,
"what do ya want for nothing?"
,
"750c783e6ab0b503eaa86e310a5db738"
)
md5test
(
chr
(
0xAA
)
*
16
,
chr
(
0xDD
)
*
50
,
"56be34521d144c88dbb8c733f0e8b3f6"
)
if
__name__
==
"__main__"
:
test
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment