开发者

PHP: How to create the uppercase MD5 value of the ASCII equivalent of a word?

I have a secret word (example. dirtydawg)

And using PHP I want t开发者_如何学编程o create the uppercase MD5 value of the ASCII equivalent of the secret word.

How do I do this????


Assuming by 'ASCII equivalent' you mean all chars in the word being ASCII values, you can do

strtoupper(md5(implode(array_map('ord', str_split('dirtydawg')))));

which is equivalent to

$secretWord = 'dirtydawg';
$hash = '';
for($i = 0; $i < strlen($secretWord); $i++) {
    $hash .= ord($secretWord[$i]);
}
echo strtoupper(md5($hash));

Also see the PHP Manual on

  • ord — Return ASCII value of character


Depending on what exactly "the uppercase MD5 value of the ASCII equivalent" means, you presumably either want:

md5(strtoupper($secretword));

or

strtoupper(md5($secretword));

PHP has pretty good documentation - have a look at http://www.php.net/md5 and http://www.php.net/strtoupper


I don't know what you mean with "ASCII equivalent", but I'm assuming what you ask for is this:

$hash = strtoupper(md5('dirtydawg'));

Or am I missing something?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜