1

I am having a hard time figuring out a reasonable way to generate a mixed-case hash in Python.

I want to generate something like: aZeEe9E

Right now I'm using MD5, which doesn't generate case-sensitive hashes.

Do any of you know how to generate a hash value consisting of upper- and lower- case characters + numbers?

-

Okay, GregS's advice worked like a charm (on the first try!):

Here is a simple example:

>>> import hashlib, base64
>>> s = 'http://gooogle.com'
>>> hash = hashlib.md5(s).digest()
>>> print hash
46c4f333fae34078a68393213bb9272d
>>> print base64.b64encode(hash)
NDZjNGYzMzNmYWUzNDA3OGE2ODM5MzIxM2JiOTI3MmQ=
Jay Taylor
  • 13,185
  • 11
  • 60
  • 85

2 Answers2

3

you can base64 encode the output of the hash. This has a couple of additional characters beyond those you mentioned.

President James K. Polk
  • 40,516
  • 21
  • 95
  • 125
3

Maybe you can use base64-encoded hashes?

Ber
  • 40,356
  • 16
  • 72
  • 88