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

Side by Side Diff: third_party/google-endpoints/Crypto/Hash/RIPEMD.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 """RIPEMD-160 cryptographic hash algorithm.
22
23 RIPEMD-160_ produces the 160 bit digest of a message.
24
25 >>> from Crypto.Hash import RIPEMD
26 >>>
27 >>> h = RIPEMD.new()
28 >>> h.update(b'Hello')
29 >>> print h.hexdigest()
30
31 RIPEMD-160 stands for RACE Integrity Primitives Evaluation Message Digest
32 with a 160 bit digest. It was invented by Dobbertin, Bosselaers, and Preneel.
33
34 This algorithm is considered secure, although it has not been scrutinized as
35 extensively as SHA-1. Moreover, it provides an informal security level of just
36 80bits.
37
38 .. _RIPEMD-160: http://homes.esat.kuleuven.be/~bosselae/ripemd160.html
39 """
40
41 _revision__ = "$Id$"
42
43 __all__ = ['new', 'digest_size', 'RIPEMD160Hash' ]
44
45 from Crypto.Util.py3compat import *
46 from Crypto.Hash.hashalgo import HashAlgo
47
48 import Crypto.Hash._RIPEMD160 as _RIPEMD160
49 hashFactory = _RIPEMD160
50
51 class RIPEMD160Hash(HashAlgo):
52 """Class that implements a RIPMD-160 hash
53
54 :undocumented: block_size
55 """
56
57 #: ASN.1 Object identifier (OID)::
58 #:
59 #: id-ripemd160 OBJECT IDENTIFIER ::= {
60 #: iso(1) identified-organization(3) teletrust(36)
61 #: algorithm(3) hashAlgorithm(2) ripemd160(1)
62 #: }
63 #:
64 #: This value uniquely identifies the RIPMD-160 algorithm.
65 oid = b("\x06\x05\x2b\x24\x03\x02\x01")
66
67 digest_size = 20
68 block_size = 64
69
70 def __init__(self, data=None):
71 HashAlgo.__init__(self, hashFactory, data)
72
73 def new(self, data=None):
74 return RIPEMD160Hash(data)
75
76 def new(data=None):
77 """Return a fresh instance of the hash object.
78
79 :Parameters:
80 data : byte string
81 The very first chunk of the message to hash.
82 It is equivalent to an early call to `RIPEMD160Hash.update()`.
83 Optional.
84
85 :Return: A `RIPEMD160Hash` object
86 """
87 return RIPEMD160Hash().new(data)
88
89 #: The size of the resulting hash in bytes.
90 digest_size = RIPEMD160Hash.digest_size
91
92 #: The internal block size of the hash algorithm in bytes.
93 block_size = RIPEMD160Hash.block_size
94
OLDNEW
« no previous file with comments | « third_party/google-endpoints/Crypto/Hash/MD5.py ('k') | third_party/google-endpoints/Crypto/Hash/SHA.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698