annotate MoinMoin/util/crypto.py @ 2657:080673c3e60a

Now nameless items can also be downloaded and removed unnecessary blank spaces in items/content.py
author Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
date Sun, 06 Jul 2014 09:25:31 +0530
parents 38b5c2746f83
children
rev   line source
1913
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
1 # Copyright: 2012-2013 MoinMoin:ThomasWaldmann
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4 """
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 MoinMoin - Cryptographic and random functions
210
316c839a6f62 crypto: better docstring, make md5crypt optional, method list as constant
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
6
316c839a6f62 crypto: better docstring, make md5crypt optional, method list as constant
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
7 Features:
316c839a6f62 crypto: better docstring, make md5crypt optional, method list as constant
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
8
316c839a6f62 crypto: better docstring, make md5crypt optional, method list as constant
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
9 - generate password recovery tokens
316c839a6f62 crypto: better docstring, make md5crypt optional, method list as constant
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
10 - verify password recovery tokens
316c839a6f62 crypto: better docstring, make md5crypt optional, method list as constant
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
11 - generate random strings of given length (for salting)
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12 """
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14 from __future__ import absolute_import, division
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16 import hashlib
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17 import hmac
232
e3bbbcb9aded crypto: fix missing import / data type
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 210
diff changeset
18 import time
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19
844
a3fe8ad5d893 deduplicate - make all code import make_uuid and UUID_LEN from MoinMoin.util.crypto
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 232
diff changeset
20 from uuid import uuid4
a3fe8ad5d893 deduplicate - make all code import make_uuid and UUID_LEN from MoinMoin.util.crypto
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 232
diff changeset
21
a3fe8ad5d893 deduplicate - make all code import make_uuid and UUID_LEN from MoinMoin.util.crypto
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 232
diff changeset
22 make_uuid = lambda: unicode(uuid4().hex)
a3fe8ad5d893 deduplicate - make all code import make_uuid and UUID_LEN from MoinMoin.util.crypto
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 232
diff changeset
23 UUID_LEN = len(make_uuid())
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24
1913
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
25 from passlib.utils import rng, getrandstr, getrandbytes, consteq, generate_password
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
26
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
28 def random_string(length, allowed_chars=None):
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 """
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 Generate a random string with given length consisting of the given characters.
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31
1913
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
32 Note: this is now just a little wrapper around passlib's randomness code.
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
33
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 :param length: length of the string
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 :param allowed_chars: string with allowed characters or None
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 to indicate all 256 byte values should be used
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 :returns: random string
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 """
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 if allowed_chars is None:
1913
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
40 s = getrandbytes(rng, length)
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41 else:
1913
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
42 s = getrandstr(rng, allowed_chars, length)
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
43 return s
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
46 # password recovery token
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
48 def generate_token(key=None, stamp=None):
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
49 """
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
50 generate a pair of a secret key and a crypto token.
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
51
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
52 you can use this to implement a password recovery functionality by
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
53 calling generate_token() and transmitting the returned token to the
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
54 (correct) user (e.g. by email) and storing the returned (secret) key
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
55 into the user's profile on the server side.
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
56
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
57 after the user received the token, he returns to the wiki, gives his
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
58 user name or email address and the token he received. read the (secret)
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
59 key from the user profile and call valid_token(key, token) to verify
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
60 if the token is valid. if it is, consider the user authenticated, remove
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
61 the secret key from his profile and let him reset his password.
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
62
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
63 :param key: give it to recompute some specific token for verification
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
64 :param stamp: give it to recompute some specific token for verification
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
65 :rtype: 2-tuple
1913
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
66 :returns: key, token (both unicode)
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
67 """
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
68 if key is None:
1913
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
69 key = generate_password(size=32)
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
70 if stamp is None:
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
71 stamp = int(time.time())
1913
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
72 h = hmac.new(str(key), str(stamp), digestmod=hashlib.sha256).hexdigest()
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
73 token = u"{0}-{1}".format(stamp, h)
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
74 return unicode(key), token
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
75
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
76
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1913
diff changeset
77 def valid_token(key, token, timeout=2 * 60 * 60):
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
78 """
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
79 check if token is valid with respect to the secret key,
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
80 the token must not be older than timeout seconds.
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
81
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
82 :param key: give the secret key to verify the token
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
83 :param token: the token to verify
1419
690fdcf93ac9 Fix for bug #184 and related user login issues.
"Miks Kalnins <MiksKalnins@MaikuMori.com>"
parents: 1397
diff changeset
84 :param timeout: timeout seconds, set to None to ignore timeout
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
85 :rtype: bool
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
86 :returns: token is valid and not timed out
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
87 """
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
88 parts = token.split('-')
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
89 if len(parts) != 2:
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
90 return False
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
91 try:
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
92 stamp = int(parts[0])
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
93 except ValueError:
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
94 return False
1419
690fdcf93ac9 Fix for bug #184 and related user login issues.
"Miks Kalnins <MiksKalnins@MaikuMori.com>"
parents: 1397
diff changeset
95 if timeout and stamp + timeout < time.time():
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
96 return False
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
97 expected_token = generate_token(key, stamp)[1]
1913
dbcadc76561a passlib support - strong crypto hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
98 return consteq(token, expected_token)
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
99
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
100
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
101 # miscellaneous
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
102
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
103 def cache_key(**kw):
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
104 """
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
105 Calculate a cache key (ascii only)
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
106
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
107 Important key properties:
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
108
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
109 * The key must be different for different <kw>.
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
110 * Key is pure ascii
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
111
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
112 :param kw: keys/values to compute cache key from
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
113 """
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
114 return hashlib.md5(repr(kw)).hexdigest()