Neueste Web-Entwicklung Tutorials
 

PHP md5() Function

<PHP String Referenz

Beispiel

Berechnen Sie den MD5 - Hash der Zeichenfolge "Hello" :

<?php
$str = "Hello";
echo md5($str);
?>
Führen Sie zB »

Definition und Verwendung

Die md5() Funktion berechnet den MD5 Hash einer Zeichenfolge.

Die md5() Funktion verwendet die RSA Data Security, Inc. MD5 Message-Digest Algorithm.

Von RFC 1321 - Der MD5 Message-Digest Algorithm: "The MD5 message-digest algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA." - "The MD5 message-digest algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA." - "The MD5 message-digest algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA." - "The MD5 message-digest algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA." bei "The MD5 message-digest algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA." - "The MD5 message-digest algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA." , "The MD5 message-digest algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA." sie "The MD5 message-digest algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA."

Um die MD5 - Hash einer Datei zu berechnen, verwenden die md5_file() Funktion.


Syntax

md5( string,raw )

Parameter Beschreibung
string Erforderlich. Die Zeichenfolge berechnet werden
raw Optional. Gibt hex oder Binär-Ausgabeformat:
  • TRUE - Raw 16 Zeichen Binärformat
  • FALSCH - Standard. 32 Zeichen Hexadezimalzahl

Technische Details

Rückgabewert: Gibt den berechneten MD5-Hash bei Erfolg oder FALSE bei einem Fehler
PHP Version: 4+
Änderungsprotokoll: Der rohe Parameter wurde optional in PHP 5.0

Mehr Beispiele

Beispiel 1

Drucken Sie das Ergebnis von md5() :

<?php
$str = "Hello";
echo "The string: ".$str."<br>";
echo "TRUE - Raw 16 character binary format: ".md5($str, TRUE)."<br>";
echo "FALSE - 32 character hex number: ".md5($str)."<br>";
?>
Führen Sie zB »

Beispiel 2

Drucken Sie das Ergebnis von md5() und dann testen:

<?php
$str = "Hello";
echo md5($str);

if (md5($str) == "8b1a9953c4611296a827abf8c47804d7")
  {
  echo "<br>Hello world!";
  exit;
  }
?>
Führen Sie zB »

<PHP String Referenz