sodium_crypto_box_seal

(PHP 7 >= 7.2.0, PHP 8)

sodium_crypto_box_sealAnonymous public-key encryption

Beschreibung

sodium_crypto_box_seal(string $message, string $public_key): string

Encrypt a message such that only the recipient can decrypt it.

Unlike with sodium_crypto_box(), you only need to know the recipient's public key to use sodium_crypto_box_seal(). One consequence of this convenience, however, is that the ciphertext isn't bound to a static public key, and is therefore not authenticated. Hence, anonymous public-key encryption.

sodium_crypto_box_seal() still provides ciphertext integrity. Just not sender identity authentication.

If you also need sender authentication, the sodium_crypto_sign() functions are likely the best place to start.

Parameter-Liste

message

The message to encrypt.

public_key

The public key that corresponds to the only key that can decrypt the message.

Rückgabewerte

A ciphertext string in the format of (one-time public key, encrypted message, authentication tag).

Beispiele

Beispiel #1 sodium_crypto_box_seal() example

<?php
$keypair 
sodium_crypto_box_keypair();
$public_key sodium_crypto_box_publickey($keypair);

// Obfuscated plaintext to make the example more fun
$plaintext_b64 "V3JpdGluZyBzb2Z0d2FyZSBpbiBQSFAgY2FuIGJlIGEgZGVsaWdodCE=";
$decoded_plaintext sodium_base642bin($plaintext_b64SODIUM_BASE64_VARIANT_ORIGINAL);

$sealed sodium_crypto_box_seal($decoded_plaintext$public_key);
var_dump(base64_encode($sealed));

$opened sodium_crypto_box_seal_open($sealed$keypair);
var_dump($opened);
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

string(120) "oRBXXAV4iQBrxlV4A21Bord8Yo/D8ZlrIIGNyaRCcGBfpz0map52I3xq6l+CST+1NSgQkbV+HiYyFjXWiWiaCGupGf+zl4bgWj/A9Adtem7Jt3h3emrMsLw="
string(41) "Writing software in PHP can be a delight!"

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

PHP cURL Error

Hello I am facing an issue with cURL in my PHP application. When trying to make a secure HTTPS request, I am getting the following error: cURL e ...

Geschrieben von nolanmaris am 27.05.2024 18:27:56
Forum: PHP Developer Forum
Online Medikamente kaufen

Hat jemand Erfahrungen damit, Medikamente online zu kaufen. Das Thema wird ja momentan groß im TV, mir fehlt noch ein wenig das Zutrauen

Geschrieben von RichardF am 27.05.2024 12:53:11
Forum: Out of Order
Abfrage über mehrere Spalten und Gruppierung

Die Verwendung von Namen anstelle von Nummern trägt dazu bei, Prozesse verständlicher zu machen. Fügen Sie die Spalten create_at und update_at ...

Geschrieben von heraldsiege am 27.05.2024 09:25:24
Forum: SQL / Datenbanken
Seltsames Verhalten von execute() oder Fehler meinerseits

Hello You can check below steps - Check for errors after executing the statement. Bind parameters to placeholders in the SQL query. Confirm t ...

Geschrieben von nolanmaris am 20.05.2024 12:12:16
Forum: SQL / Datenbanken