php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67451 MD5 and national characters
Submitted: 2014-06-16 09:03 UTC Modified: 2014-06-16 10:04 UTC
From: frenky dot pv at atlas dot cz Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.5.13 OS: Win2012, 64bit
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: frenky dot pv at atlas dot cz
New email:
PHP Version: OS:

 

 [2014-06-16 09:03 UTC] frenky dot pv at atlas dot cz
Description:
------------
PHP:
  md5('házená') = 3d560aed38ceab4eb6892b7aa377d39a  (wrong)

MySQL:
  SELECT MD5('házená') = 6270f1b53a892b56531f91e66d5d7139  (correct)

'házená' is the Czech word translation into English 'handball'.

Have something similar was written:
http://cz1.php.net/manual/en/function.md5.php#31238


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-06-16 10:04 UTC] johannes@php.net
-Status: Open +Status: Not a bug
 [2014-06-16 10:04 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

PHP knows little about encodings the md5() function works on the binary string array which uses whatever encoding you are using to save your file. From a quick test it seems your database uses UTF-8 while your code uses Latin 1 (ISO-8859-1)

$ cat t.php 
<?php
echo md5('házená');

$ php t.php
6270f1b53a892b56531f91e66d5d7139

$ iconv -f utf-8 -t iso-8859-1 t.php | php
3d560aed38ceab4eb6892b7aa377d39a
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 23:00:02 2026 UTC