0

What is the correct and/or standard way of creating password hashes from user input when this user input does include also non ascii characters ?

I have noticed that when I generate MD5 hashes using only ASCII chars I always get the same result. But lets say user want's his/hers password to be 'pöllö' (Owl, in English).

Here is an example from a few online MD5 hash generators generating a hash for pöllö

http://www.md5hashgenerator.com/index.php Hash: 0cbe7f5ca855599480e4313e63e8093d

http://www.miraclesalad.com/webtools/md5.php Hash: 0f6b1c5d67c201eb1c3c37300b8be077

  • 2
    This is a question of charset. Your first website uses iso-8859-15, the second one utf-8. The first is used for East European languages (almost) only but uses a 8 bits code, where utf-8 suits all languages in the world (or tries to) but characters may be coded on 8 to 32 bits each. – Cilyan Jan 09 '14 at 08:12

2 Answers2

0

Use the md5 class in the hashlib module

norlesh
  • 1,749
  • 11
  • 23
0

In python, this should work.

#!/usr/bin/env python
# -*- coding: utf-8 -*- 
import  hashlib

m = hashlib.md5()
m.update("pöllö")
print(m.hexdigest())

The comments on top is a source header declaration to be able to use non ascii characters. (src-- Working with utf-8 encoding in Python source)

Community
  • 1
  • 1
runedisc
  • 50
  • 8