开发者

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

开发者 https://www.devze.com 2023-01-02 12:34 出处:网络
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.

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

精彩评论

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