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:	3fe0a20f148d3fb2d9bf3d40325cadf8b53e638d
aad:	e1ec2589228bc110f5ba2cbcf178a6625372c557
Iv:	1d820c3b59b898e0a8e59bb3c8a3317b69ffcb6e

crypt:	3a35c1ad6259b60bd1171a4c531249bf37af5c555a59518fa09d3946596ec1cba738b55e4dd6444752e6b4d9ebdd7658c58210ab8b9b2cfa3b4c334cecf0480e2cd12f6b7b1d838f421193408196ade7251867cd0830094868dba8a3

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