[Python-3000-checkins] r55303 - in python/branches/p3yk: Doc/lib/lib.tex Doc/lib/libmd5.tex Doc/lib/libsha.tex Lib/md5.py Lib/test/test_md5.py Lib/test/test_pep247.py Lib/test/test_sha.py Lib/test/test_tarfile.py Lib/uuid.py Misc/NEWS

brett.cannon python-3000-checkins at python.org
Mon May 14 04:22:24 CEST 2007


Author: brett.cannon
Date: Mon May 14 04:22:22 2007
New Revision: 55303

Removed:
   python/branches/p3yk/Doc/lib/libmd5.tex
   python/branches/p3yk/Doc/lib/libsha.tex
   python/branches/p3yk/Lib/md5.py
   python/branches/p3yk/Lib/test/test_md5.py
   python/branches/p3yk/Lib/test/test_sha.py
Modified:
   python/branches/p3yk/Doc/lib/lib.tex
   python/branches/p3yk/Lib/test/test_pep247.py
   python/branches/p3yk/Lib/test/test_tarfile.py
   python/branches/p3yk/Lib/uuid.py
   python/branches/p3yk/Misc/NEWS
Log:
Remove the md5 and sha modules.


Modified: python/branches/p3yk/Doc/lib/lib.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/lib.tex	(original)
+++ python/branches/p3yk/Doc/lib/lib.tex	Mon May 14 04:22:22 2007
@@ -182,8 +182,6 @@
 \input{libcrypto}               % Cryptographic Services
 \input{libhashlib}
 \input{libhmac}
-\input{libmd5}
-\input{libsha}
 
 % =============
 % FILE & DATABASE STORAGE

Deleted: /python/branches/p3yk/Doc/lib/libmd5.tex
==============================================================================
--- /python/branches/p3yk/Doc/lib/libmd5.tex	Mon May 14 04:22:22 2007
+++ (empty file)
@@ -1,92 +0,0 @@
-\section{\module{md5} ---
-         MD5 message digest algorithm}
-
-\declaremodule{builtin}{md5}
-\modulesynopsis{RSA's MD5 message digest algorithm.}
-
-\deprecated{2.5}{Use the \refmodule{hashlib} module instead.}
-
-This module implements the interface to RSA's MD5 message digest
-\index{message digest, MD5}
-algorithm (see also Internet \rfc{1321}).  Its use is quite
-straightforward:\ use \function{new()} to create an md5 object.
-You can now feed this object with arbitrary strings using the
-\method{update()} method, and at any point you can ask it for the
-\dfn{digest} (a strong kind of 128-bit checksum,
-a.k.a. ``fingerprint'') of the concatenation of the strings fed to it
-so far using the \method{digest()} method.
-\index{checksum!MD5}
-
-For example, to obtain the digest of the string \code{'Nobody inspects
-the spammish repetition'}:
-
-\begin{verbatim}
->>> import md5
->>> m = md5.new()
->>> m.update("Nobody inspects")
->>> m.update(" the spammish repetition")
->>> m.digest()
-'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'
-\end{verbatim}
-
-More condensed:
-
-\begin{verbatim}
->>> md5.new("Nobody inspects the spammish repetition").digest()
-'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'
-\end{verbatim}
-
-The following values are provided as constants in the module and as
-attributes of the md5 objects returned by \function{new()}:
-
-\begin{datadesc}{digest_size}
-  The size of the resulting digest in bytes.  This is always
-  \code{16}.
-\end{datadesc}
-
-The md5 module provides the following functions:
-
-\begin{funcdesc}{new}{\optional{arg}}
-Return a new md5 object.  If \var{arg} is present, the method call
-\code{update(\var{arg})} is made.
-\end{funcdesc}
-
-\begin{funcdesc}{md5}{\optional{arg}}
-For backward compatibility reasons, this is an alternative name for the
-\function{new()} function.
-\end{funcdesc}
-
-An md5 object has the following methods:
-
-\begin{methoddesc}[md5]{update}{arg}
-Update the md5 object with the string \var{arg}.  Repeated calls are
-equivalent to a single call with the concatenation of all the
-arguments: \code{m.update(a); m.update(b)} is equivalent to
-\code{m.update(a+b)}.
-\end{methoddesc}
-
-\begin{methoddesc}[md5]{digest}{}
-Return the digest of the strings passed to the \method{update()}
-method so far.  This is a 16-byte string which may contain
-non-\ASCII{} characters, including null bytes.
-\end{methoddesc}
-
-\begin{methoddesc}[md5]{hexdigest}{}
-Like \method{digest()} except the digest is returned as a string of
-length 32, containing only hexadecimal digits.  This may 
-be used to exchange the value safely in email or other non-binary
-environments.
-\end{methoddesc}
-
-\begin{methoddesc}[md5]{copy}{}
-Return a copy (``clone'') of the md5 object.  This can be used to
-efficiently compute the digests of strings that share a common initial
-substring.
-\end{methoddesc}
-
-
-\begin{seealso}
-  \seemodule{sha}{Similar module implementing the Secure Hash
-                  Algorithm (SHA).  The SHA algorithm is considered a
-                  more secure hash.}
-\end{seealso}

Deleted: /python/branches/p3yk/Doc/lib/libsha.tex
==============================================================================
--- /python/branches/p3yk/Doc/lib/libsha.tex	Mon May 14 04:22:22 2007
+++ (empty file)
@@ -1,83 +0,0 @@
-\section{\module{sha} ---
-         SHA-1 message digest algorithm}
-
-\declaremodule{builtin}{sha}
-\modulesynopsis{NIST's secure hash algorithm, SHA.}
-\sectionauthor{Fred L. Drake, Jr.}{fdrake at acm.org}
-
-\deprecated{2.5}{Use the \refmodule{hashlib} module instead.}
-
-
-This module implements the interface to NIST's\index{NIST} secure hash 
-algorithm,\index{Secure Hash Algorithm} known as SHA-1.  SHA-1 is an
-improved version of the original SHA hash algorithm.  It is used in
-the same way as the \refmodule{md5} module:\ use \function{new()}
-to create an sha object, then feed this object with arbitrary strings
-using the \method{update()} method, and at any point you can ask it
-for the \dfn{digest} of the concatenation of the strings fed to it
-so far.\index{checksum!SHA}  SHA-1 digests are 160 bits instead of
-MD5's 128 bits.
-
-
-\begin{funcdesc}{new}{\optional{string}}
-  Return a new sha object.  If \var{string} is present, the method
-  call \code{update(\var{string})} is made.
-\end{funcdesc}
-
-
-The following values are provided as constants in the module and as
-attributes of the sha objects returned by \function{new()}:
-
-\begin{datadesc}{blocksize}
-  Size of the blocks fed into the hash function; this is always
-  \code{1}.  This size is used to allow an arbitrary string to be
-  hashed.
-\end{datadesc}
-
-\begin{datadesc}{digest_size}
-  The size of the resulting digest in bytes.  This is always
-  \code{20}.
-\end{datadesc}
-
-
-An sha object has the same methods as md5 objects:
-
-\begin{methoddesc}[sha]{update}{arg}
-Update the sha object with the string \var{arg}.  Repeated calls are
-equivalent to a single call with the concatenation of all the
-arguments: \code{m.update(a); m.update(b)} is equivalent to
-\code{m.update(a+b)}.
-\end{methoddesc}
-
-\begin{methoddesc}[sha]{digest}{}
-Return the digest of the strings passed to the \method{update()}
-method so far.  This is a 20-byte string which may contain
-non-\ASCII{} characters, including null bytes.
-\end{methoddesc}
-
-\begin{methoddesc}[sha]{hexdigest}{}
-Like \method{digest()} except the digest is returned as a string of
-length 40, containing only hexadecimal digits.  This may 
-be used to exchange the value safely in email or other non-binary
-environments.
-\end{methoddesc}
-
-\begin{methoddesc}[sha]{copy}{}
-Return a copy (``clone'') of the sha object.  This can be used to
-efficiently compute the digests of strings that share a common initial
-substring.
-\end{methoddesc}
-
-\begin{seealso}
-  \seetitle[http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf]
-    {Secure Hash Standard}
-    {The Secure Hash Algorithm is defined by NIST document FIPS
-     PUB 180-2:
-     \citetitle[http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf]
-        {Secure Hash Standard}, published in August 2002.}
-
-  \seetitle[http://csrc.nist.gov/encryption/tkhash.html]
-           {Cryptographic Toolkit (Secure Hashing)}
-           {Links from NIST to various information on secure hashing.}
-\end{seealso}
-

Deleted: /python/branches/p3yk/Lib/md5.py
==============================================================================
--- /python/branches/p3yk/Lib/md5.py	Mon May 14 04:22:22 2007
+++ (empty file)
@@ -1,10 +0,0 @@
-# $Id$
-#
-#  Copyright (C) 2005   Gregory P. Smith (greg at electricrain.com)
-#  Licensed to PSF under a Contributor Agreement.
-
-from hashlib import md5
-new = md5
-
-blocksize = 1        # legacy value (wrong in any useful sense)
-digest_size = 16

Deleted: /python/branches/p3yk/Lib/test/test_md5.py
==============================================================================
--- /python/branches/p3yk/Lib/test/test_md5.py	Mon May 14 04:22:22 2007
+++ (empty file)
@@ -1,58 +0,0 @@
-# Testing md5 module
-
-import unittest
-from md5 import md5
-from test import test_support
-
-def hexstr(s):
-    import string
-    h = string.hexdigits
-    r = ''
-    for c in s:
-        i = ord(c)
-        r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
-    return r
-
-class MD5_Test(unittest.TestCase):
-
-    def md5test(self, s, expected):
-        self.assertEqual(hexstr(md5(s).digest()), expected)
-        self.assertEqual(md5(s).hexdigest(), expected)
-
-    def test_basics(self):
-        eq = self.md5test
-        eq('', 'd41d8cd98f00b204e9800998ecf8427e')
-        eq('a', '0cc175b9c0f1b6a831c399e269772661')
-        eq('abc', '900150983cd24fb0d6963f7d28e17f72')
-        eq('message digest', 'f96b697d7cb7938d525a2f31aaf161d0')
-        eq('abcdefghijklmnopqrstuvwxyz', 'c3fcd3d76192e4007dfb496cca67e13b')
-        eq('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
-           'd174ab98d277d9f5a5611c2c9f419d9f')
-        eq('12345678901234567890123456789012345678901234567890123456789012345678901234567890',
-           '57edf4a22be3c955ac49da2e2107b67a')
-
-    def test_hexdigest(self):
-        # hexdigest is new with Python 2.0
-        m = md5('testing the hexdigest method')
-        h = m.hexdigest()
-        self.assertEqual(hexstr(m.digest()), h)
-
-    def test_large_update(self):
-        aas = 'a' * 64
-        bees = 'b' * 64
-        cees = 'c' * 64
-
-        m1 = md5()
-        m1.update(aas)
-        m1.update(bees)
-        m1.update(cees)
-
-        m2 = md5()
-        m2.update(aas + bees + cees)
-        self.assertEqual(m1.digest(), m2.digest())
-
-def test_main():
-    test_support.run_unittest(MD5_Test)
-
-if __name__ == '__main__':
-    test_main()

Modified: python/branches/p3yk/Lib/test/test_pep247.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_pep247.py	(original)
+++ python/branches/p3yk/Lib/test/test_pep247.py	Mon May 14 04:22:22 2007
@@ -3,7 +3,7 @@
 # hashing algorithms.
 #
 
-import md5, sha, hmac
+import hmac
 
 def check_hash_module(module, key=None):
     assert hasattr(module, 'digest_size'), "Must have digest_size"
@@ -45,6 +45,4 @@
 
 
 if __name__ == '__main__':
-    check_hash_module(md5)
-    check_hash_module(sha)
     check_hash_module(hmac, key='abc')

Deleted: /python/branches/p3yk/Lib/test/test_sha.py
==============================================================================
--- /python/branches/p3yk/Lib/test/test_sha.py	Mon May 14 04:22:22 2007
+++ (empty file)
@@ -1,52 +0,0 @@
-# Testing sha module (NIST's Secure Hash Algorithm)
-
-# use the three examples from Federal Information Processing Standards
-# Publication 180-1, Secure Hash Standard,  1995 April 17
-# http://www.itl.nist.gov/div897/pubs/fip180-1.htm
-
-import sha
-import unittest
-from test import test_support
-
-
-class SHATestCase(unittest.TestCase):
-    def check(self, data, digest):
-        # Check digest matches the expected value
-        obj = sha.new(data)
-        computed = obj.hexdigest()
-        self.assert_(computed == digest)
-
-        # Verify that the value doesn't change between two consecutive
-        # digest operations.
-        computed_again = obj.hexdigest()
-        self.assert_(computed == computed_again)
-
-        # Check hexdigest() output matches digest()'s output
-        digest = obj.digest()
-        hexd = ""
-        for c in digest:
-            hexd += '%02x' % ord(c)
-        self.assert_(computed == hexd)
-
-    def test_case_1(self):
-        self.check("abc",
-                   "a9993e364706816aba3e25717850c26c9cd0d89d")
-
-    def test_case_2(self):
-        self.check("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
-                   "84983e441c3bd26ebaae4aa1f95129e5e54670f1")
-
-    def test_case_3(self):
-        self.check("a" * 1000000,
-                   "34aa973cd4c4daa4f61eeb2bdbad27316534016f")
-
-    def test_case_4(self):
-        self.check(chr(0xAA) * 80,
-                   '4ca0ef38f1794b28a8f8ee110ee79d48ce13be25')
-
-def test_main():
-    test_support.run_unittest(SHATestCase)
-
-
-if __name__ == "__main__":
-    test_main()

Modified: python/branches/p3yk/Lib/test/test_tarfile.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_tarfile.py	(original)
+++ python/branches/p3yk/Lib/test/test_tarfile.py	Mon May 14 04:22:22 2007
@@ -5,7 +5,7 @@
 import shutil
 import tempfile
 import StringIO
-import md5
+from hashlib import md5
 import errno
 
 import unittest
@@ -25,7 +25,7 @@
     bz2 = None
 
 def md5sum(data):
-    return md5.new(data).hexdigest()
+    return md5(data).hexdigest()
 
 def path(path):
     return test_support.findfile(path)

Modified: python/branches/p3yk/Lib/uuid.py
==============================================================================
--- python/branches/p3yk/Lib/uuid.py	(original)
+++ python/branches/p3yk/Lib/uuid.py	Mon May 14 04:22:22 2007
@@ -535,8 +535,8 @@
 
 def uuid3(namespace, name):
     """Generate a UUID from the MD5 hash of a namespace UUID and a name."""
-    import md5
-    hash = md5.md5(namespace.bytes + name).digest()
+    import hashlib
+    hash = hashlib.md5(namespace.bytes + name).digest()
     return UUID(bytes=hash[:16], version=3)
 
 def uuid4():

Modified: python/branches/p3yk/Misc/NEWS
==============================================================================
--- python/branches/p3yk/Misc/NEWS	(original)
+++ python/branches/p3yk/Misc/NEWS	Mon May 14 04:22:22 2007
@@ -178,6 +178,8 @@
 Library
 -------
 
+- Remove md5 and sha.  Both have been deprecated since Python 2.5.
+
 - Remove Bastion and rexec as they have been disabled since Python 2.3 (this
   also leads to the C API support for restricted execution).
 


More information about the Python-3000-checkins mailing list