ChaCha20 Poly1305 PHP implimentation (CHACHA20 POLY1305 PHP CLASS)

Download ChaCha20 Poly1305 PHP Class

Result:

plaintext:	Lorem Ipsum is simply dummy text of the printing and typesetting industry...

r_key:	11734ed31c757aa0d9c8e6c9f4bf9ea9b2bba5c0
aad:	b83919b7c7d9460798fd9a84d6f4bf266a3a8c6d
Iv:	5f73c5e1bdee81bbc21d772c012b8ebbe304be6e

crypt:	c8ba093dbc7fefb444ef65b1f878089f507c36a61b0809ed33d5007fc43d6287a7ac92eb44fb786281a7a22ede6d34a889a9c2f354ccb05fcb2027b9dec732e53c687c55b06bc273a300586606c03c2caa404286ad83dc0b713ff733

decrypt:	Lorem Ipsum is simply dummy text of the printing and typesetting industry...

Code example:

<?php include("AEAD_CHACHA20_POLY1305.php"); $x = new AEAD_CHACHA20_POLY1305; $plaintext = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry...'; $r_key = sha1(sha1(sha1(mt_rand(0, 99999) + time()))); $aad = sha1(sha1(sha1(mt_rand(0, 99999) + time()))); $Iv = sha1(sha1(sha1(mt_rand(0, 99999) + time()))); $crypt = $x->chacha20_aead_encrypt($aad, $Key, $Iv, '07000000', $plaintext); $decrypt = $x->chacha20_aead_decrypt($aad, $Key, $Iv, '07000000', $crypt); $out = '<pre>'; $out .= "plaintext:\t".$plaintext."\n\n"; $out .= "r_key:\t".$r_key."\n"; $out.= "aad:\t".$aad."\n"; $out .= "Iv:\t".$Iv."\n\n"; $out .= "crypt:\t".$crypt."\n\n"; $out .= "decrypt:\t".$decrypt."\n\n"; $out .= '</pre>'; echo $out; ?>

КОНЬЯКОВ.ру > pubs > phpclasses > chacha20-and-poly130