mdecrypt_generic

(PHP 4 >= 4.0.2, PHP 5, PHP 7 < 7.2.0, PECL mcrypt >= 1.0.0)

mdecrypt_genericDecrypts data

Warnung

Diese Funktion wurde in PHP 7.1.0 als DEPRECATED (veraltet) markiert und ist seit PHP 7.2.0 ENTFERNT. Von der Verwendung dieser Funktion wird dringend abgeraten.

Beschreibung

mdecrypt_generic(resource $td, string $data): string

This function decrypts data. Note that the length of the returned string can in fact be longer than the unencrypted string, due to the padding of the data.

Parameter-Liste

td

An encryption descriptor returned by mcrypt_module_open()

data

Encrypted data.

Rückgabewerte

Returns decrypted string.

Beispiele

Beispiel #1 mdecrypt_generic() Example

<?php
    
/* Data */
    
$key 'this is a very long key, even too long for the cipher';
    
$plain_text 'very important data';

    
/* Open module, and create IV */
    
$td mcrypt_module_open('des''''ecb''');
    
$key substr($key0mcrypt_enc_get_key_size($td));
    
$iv_size mcrypt_enc_get_iv_size($td);
    
$iv mcrypt_create_iv($iv_sizeMCRYPT_RAND);

    
/* Initialize encryption handle */
    
if (mcrypt_generic_init($td$key$iv) != -1) {

        
/* Encrypt data */
        
$c_t mcrypt_generic($td$plain_text);
        
mcrypt_generic_deinit($td);

        
/* Reinitialize buffers for decryption */
        
mcrypt_generic_init($td$key$iv);
        
$p_t mdecrypt_generic($td$c_t);

        
/* Clean up */
        
mcrypt_generic_deinit($td);
        
mcrypt_module_close($td);
    }

    if (
strncmp($p_t$plain_textstrlen($plain_text)) == 0) {
        echo 
"ok\n";
    } else {
        echo 
"error\n";
    }
?>

The example above shows how to check if the data before the encryption is the same as the data after the decryption. It is very important to reinitialize the encryption buffer with mcrypt_generic_init() before you try to decrypt the data.

The decryption handle should always be initialized with mcrypt_generic_init() with a key and an IV before calling this function. Where the encryption is done, you should free the encryption buffers by calling mcrypt_generic_deinit(). See mcrypt_module_open() for an example.

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Experienced Front-End Developer skills?

What specific skills and experiences should an experienced Front-End Web Developer possess, particularly in the areas of JavaScript, HTML, CSS, an ...

Geschrieben von BhambriRohunu am 03.06.2024 12:11:17
Forum: HTML, JavaScript, AJAX, jQuery, CSS, Bootstrap, LESS
Staging vs Pre-production: Key Differences?

What are the key differences between staging and pre-production environments in software development, and how do they contribute to the overall de ...

Geschrieben von GimmickTadpade am 03.06.2024 09:44:33
Forum: Entwicklungsumgebungen
Which modern CSS framework excels?

What are the distinguishing features, advantages, and potential drawbacks of contemporary CSS frameworks and libraries tailored specifically for s ...

Geschrieben von AnjanaTelaney am 03.06.2024 09:12:46
Forum: HTML, JavaScript, AJAX, jQuery, CSS, Bootstrap, LESS
"How graphic designer learns coding?"

What strategies can a graphic designer employ to effectively transition into the realm of front-end and web development, considering their existin ...

Geschrieben von SangakaraMoory am 03.06.2024 08:33:30
Forum: Grafik / Design / Flash ...