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

Side by Side Diff: third_party/google-endpoints/Crypto/Hash/MD2.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 """MD2 cryptographic hash algorithm.
22
23 MD2 is specified in RFC1319_ and it produces the 128 bit digest of a message.
24
25 >>> from Crypto.Hash import MD2
26 >>>
27 >>> h = MD2.new()
28 >>> h.update(b'Hello')
29 >>> print h.hexdigest()
30
31 MD2 stand for Message Digest version 2, and it was invented by Rivest in 1989.
32
33 This algorithm is both slow and insecure. Do not use it for new designs.
34
35 .. _RFC1319: http://tools.ietf.org/html/rfc1319
36 """
37
38 _revision__ = "$Id$"
39
40 __all__ = ['new', 'digest_size', 'MD2Hash' ]
41
42 from Crypto.Util.py3compat import *
43 from Crypto.Hash.hashalgo import HashAlgo
44
45 import Crypto.Hash._MD2 as _MD2
46 hashFactory = _MD2
47
48 class MD2Hash(HashAlgo):
49 """Class that implements an MD2 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) 2
59 #: }
60 #:
61 #: This value uniquely identifies the MD2 algorithm.
62 oid = b('\x06\x08\x2a\x86\x48\x86\xf7\x0d\x02\x02')
63
64 digest_size = 16
65 block_size = 16
66
67 def __init__(self, data=None):
68 HashAlgo.__init__(self, hashFactory, data)
69
70 def new(self, data=None):
71 return MD2Hash(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 `MD2Hash.update()`.
80 Optional.
81
82 :Return: An `MD2Hash` object
83 """
84 return MD2Hash().new(data)
85
86 #: The size of the resulting hash in bytes.
87 digest_size = MD2Hash.digest_size
88
89 #: The internal block size of the hash algorithm in bytes.
90 block_size = MD2Hash.block_size
91
OLDNEW
« no previous file with comments | « third_party/google-endpoints/Crypto/Hash/HMAC.py ('k') | third_party/google-endpoints/Crypto/Hash/MD4.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698