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:	627c2dabb3cd5bd4288cf9d83ab7c72a4742d8f3
aad:	b5cb8ec6691e0d8246131b0699cb4fea73e4000d
Iv:	8fd82637a0a39ec6a1ee803ba2b403ec94344ba1

crypt:	d763c9f8913df5b6788d458a81c3c01405154c3286d68085a3b2ba3de6716ef8a28d2b7887b062699bcbed822e6ce7dd32044bea74c250e48b7af3a88304e7626aa5c8b06cd073c7fbb9c7b699d0ecc1e445e9a1b8c8ded9d5468236

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