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:	f2975005a1f25f767186b59fc8f48c325c8d5fe0
aad:	7c929d3bb45ab6cc0a1fee21fe7813350ce7d847
Iv:	37e89b8b79177a51ddfee84970c210b81c2c80af

crypt:	9034a351203c9d646cc6a48e1b96012beff0f9a9dd2bf0cef41c26b820c1f123492ecde80dd45f774992b5a9dee0422a2fee6d0be726e736dd3e65cfd245370891126e77c88e8198e71a1d5750c720fdb0d17be67206db208765a696

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