Skip to Main Content
PHP 5 Kochbuch, Third Edition
book

PHP 5 Kochbuch, Third Edition

by David Sklar, Adam Trachtenberg, Carsten Lucke, Matthias Brusdeylins, Ulrich Speidel, Stephan Schmidt
September 2009
Intermediate to advanced content levelIntermediate to advanced
912 pages
48h 11m
German
O'Reilly Verlag
Content preview from PHP 5 Kochbuch, Third Edition

17.7 Daten ver- und entschlüsseln

Problem

Sie wollen mit einem von mehreren gebräuchlichen Algorithmen Daten ver- und entschlüsseln.

Lösung

Benutzen Sie die PHP-Erweiterung mcrypt:

$schluessel  = 'That golden key that opes the palace of eternity.';
$daten = 'The chicken escapes at dawn. Send help with Mr. Blue.';
$alg  = MCRYPT_BLOWFISH;
$modus = MCRYPT_MODE_CBC;

$iv = mcrypt_create_iv(mcrypt_get_iv_size($alg,$modus),MCRYPT_DEV_URANDOM);
$verschluesselte_daten = mcrypt_encrypt($alg, $schluessel, $daten, $modus, $iv);
$zeichentext = base64_encode($verschluesselte_daten);

print $zeichentext."\n";
$decodiert = mcrypt_decrypt($alg,$key,base64_decode($zeichentext),$modus,$iv);
print $decodiert."\n";
NNB9WnuCYjyd3Y7vUh7XDfWFCWnQY0BsMehHNmBHbGOdJ3cM+yghABb/XyrJ+w3xz9tms74/a70= ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP programmieren unter Windows

PHP programmieren unter Windows

Arno Hollosi
CSS Kochbuch, 3rd Edition

CSS Kochbuch, 3rd Edition

Joergen Lang, Christopher Schmitt

Publisher Resources

ISBN: 9783868993271Purchase book