note 125178 added to function.sodium-crypto-secretbox
| From: | celsofontes@php.net | Date: | Wed, 08 Jul 2020 14:20:36 +0000 |
| Subject: | note 125178 added to function.sodium-crypto-secretbox | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-214849@lists.php.net to get a copy of this message | ||
An example to how encrypt or decrypt using sodium:
<?php
$key = random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES);
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
$ciphertext = sodium_crypto_secretbox("Hello World !", $nonce, $key);
$plaintext = sodium_crypto_secretbox_open($ciphertext, $nonce, $key);
if ($plaintext === false) {
throw new Exception("Bad ciphertext");
}
echo $plaintext;
----
Server IP: 45.112.84.4
Probable Submitter: 177.234.144.170 (proxied: 186.205.27.21)
----
Manual Page -- http://php.net/manual/en/function.sodium-crypto-secretbox.php
Edit -- https://master.php.net/note/edit/125178
Del: integrated -- https://master.php.net/note/delete/125178/integrated
Del: useless -- https://master.php.net/note/delete/125178/useless
Del: bad code -- https://master.php.net/note/delete/125178/bad+code
Del: spam -- https://master.php.net/note/delete/125178/spam
Del: non-english -- https://master.php.net/note/delete/125178/non-english
Del: in docs -- https://master.php.net/note/delete/125178/in+docs
Del: other reasons-- https://master.php.net/note/delete/125178
Reject -- https://master.php.net/note/reject/125178
Search -- https://master.php.net/manage/user-notes.php