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
afa2973d
Kaydet (Commit)
afa2973d
authored
Haz 27, 2012
tarafından
Christian Heimes
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 10924: Fixed mksalt() to use a RNG that is suitable for cryptographic purpose
üst
39b1e5df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
crypt.py
Lib/crypt.py
+8
-7
NEWS
Misc/NEWS
+10
-0
No files found.
Lib/crypt.py
Dosyayı görüntüle @
afa2973d
"""Wrapper to the POSIX crypt library call and associated functionality."""
"""Wrapper to the POSIX crypt library call and associated functionality."""
import
_crypt
import
_crypt
import
string
import
string
as
_string
from
random
import
choice
from
random
import
SystemRandom
as
_SystemRandom
from
collections
import
namedtuple
from
collections
import
namedtuple
as
_namedtuple
_saltchars
=
string
.
ascii_letters
+
string
.
digits
+
'./'
_saltchars
=
_string
.
ascii_letters
+
_string
.
digits
+
'./'
_sr
=
_SystemRandom
()
class
_Method
(
namedtuple
(
'_Method'
,
'name ident salt_chars total_size'
)):
class
_Method
(
_
namedtuple
(
'_Method'
,
'name ident salt_chars total_size'
)):
"""Class representing a salt method per the Modular Crypt Format or the
"""Class representing a salt method per the Modular Crypt Format or the
legacy 2-character crypt method."""
legacy 2-character crypt method."""
...
@@ -18,7 +19,6 @@ class _Method(namedtuple('_Method', 'name ident salt_chars total_size')):
...
@@ -18,7 +19,6 @@ class _Method(namedtuple('_Method', 'name ident salt_chars total_size')):
return
'<crypt.METHOD_{}>'
.
format
(
self
.
name
)
return
'<crypt.METHOD_{}>'
.
format
(
self
.
name
)
def
mksalt
(
method
=
None
):
def
mksalt
(
method
=
None
):
"""Generate a salt for the specified method.
"""Generate a salt for the specified method.
...
@@ -28,7 +28,7 @@ def mksalt(method=None):
...
@@ -28,7 +28,7 @@ def mksalt(method=None):
if
method
is
None
:
if
method
is
None
:
method
=
methods
[
0
]
method
=
methods
[
0
]
s
=
'${}$'
.
format
(
method
.
ident
)
if
method
.
ident
else
''
s
=
'${}$'
.
format
(
method
.
ident
)
if
method
.
ident
else
''
s
+=
''
.
join
(
choice
(
_saltchars
)
for
_
in
range
(
method
.
salt_chars
))
s
+=
''
.
join
(
_sr
.
sample
(
_saltchars
,
method
.
salt_chars
))
return
s
return
s
...
@@ -60,3 +60,4 @@ for _method in (METHOD_SHA512, METHOD_SHA256, METHOD_MD5):
...
@@ -60,3 +60,4 @@ for _method in (METHOD_SHA512, METHOD_SHA256, METHOD_MD5):
methods
.
append
(
_method
)
methods
.
append
(
_method
)
methods
.
append
(
METHOD_CRYPT
)
methods
.
append
(
METHOD_CRYPT
)
del
_result
,
_method
del
_result
,
_method
Misc/NEWS
Dosyayı görüntüle @
afa2973d
...
@@ -7,6 +7,16 @@ What's New in Python 3.3.0 Beta 2?
...
@@ -7,6 +7,16 @@ What's New in Python 3.3.0 Beta 2?
*Release date: xx-xxx-2012*
*Release date: xx-xxx-2012*
Core and Builtins
-----------------
Library
-------
- Issue 10924: Fixed mksalt() to use a RNG that is suitable for cryptographic
purpose.
Extension Modules
Extension Modules
-----------------
-----------------
...
...
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