Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: third_party/google-endpoints/Crypto/Hash/MD4.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # -*- coding: utf-8 -*-
2 #
3 # ===================================================================
4 # The contents of this file are dedicated to the public domain. To
5 # the extent that dedication to the public domain is not available,
6 # everyone is granted a worldwide, perpetual, royalty-free,
7 # non-exclusive license to exercise all rights associated with the
8 # contents of this file for any purpose whatsoever.
9 # No rights are reserved.
10 #
11 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
12 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
15 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
16 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 # SOFTWARE.
19 # ===================================================================
20
21 """MD4 cryptographic hash algorithm.
22
23 MD4 is specified in RFC1320_ and produces the 128 bit digest of a message.
24
25 >>> from Crypto.Hash import MD4
26 >>>
27 >>> h = MD4.new()
28 >>> h.update(b'Hello')
29 >>> print h.hexdigest()
30
31 MD4 stand for Message Digest version 4, and it was invented by Rivest in 1990.
32
33 This algorithm is insecure. Do not use it for new designs.
34
35 .. _RFC1320: http://tools.ietf.org/html/rfc1320
36 """
37
38 _revision__ = "$Id$"
39
40 __all__ = ['new', 'digest_size', 'MD4Hash' ]
41
42 from Crypto.Util.py3compat import *
43 from Crypto.Hash.hashalgo import HashAlgo
44
45 import Crypto.Hash._MD4 as _MD4
46 hashFactory = _MD4
47
48 class MD4Hash(HashAlgo):
49 """Class that implements an MD4 hash
50
51 :undocumented: block_size
52 """
53
54 #: ASN.1 Object identifier (OID)::
55 #:
56 #: id-md2 OBJECT IDENTIFIER ::= {
57 #: iso(1) member-body(2) us(840) rsadsi(113549)
58 #: digestAlgorithm(2) 4
59 #: }
60 #:
61 #: This value uniquely identifies the MD4 algorithm.
62 oid = b('\x06\x08\x2a\x86\x48\x86\xf7\x0d\x02\x04')
63
64 digest_size = 16
65 block_size = 64
66
67 def __init__(self, data=None):
68 HashAlgo.__init__(self, hashFactory, data)
69
70 def new(self, data=None):
71 return MD4Hash(data)
72
73 def new(data=None):
74 """Return a fresh instance of the hash object.
75
76 :Parameters:
77 data : byte string
78 The very first chunk of the message to hash.
79 It is equivalent to an early call to `MD4Hash.update()`.
80 Optional.
81
82 :Return: A `MD4Hash` object
83 """
84 return MD4Hash().new(data)
85
86 #: The size of the resulting hash in bytes.
87 digest_size = MD4Hash.digest_size
88
89 #: The internal block size of the hash algorithm in bytes.
90 block_size = MD4Hash.block_size
91
OLDNEW
« no previous file with comments | « third_party/google-endpoints/Crypto/Hash/MD2.py ('k') | third_party/google-endpoints/Crypto/Hash/MD5.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698