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:	50ca6d93f19330ddc1a9647eed94b4878a61bb34
aad:	cba95e3f43944231fb25afbefac068388b5ddeb8
Iv:	6fbd6b1c67bbda554b4345d92bfd0a7b5335737d

crypt:	056bd52ef6795097c175a48f5b01a5aaab657ea1bd87f21f564029d6f9b6ca4a963744ff0f9f6e9cdd2b1efad03d5d426f9297e68096bd7871b6ce2ff1a238991e8b07b7f9a8fb661dad6192a06b456c2413d6b421f979bff974ce18

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