Encryption helper

Named example: 5-asymmetric-to-public

Do not use for secrets!

This allows you to sign something with your private key, and anyone with your public key can be sure you created it.

<?php //-------------------------------------------------- // 1. Create a key encryption::key_asymmetric_create('my-key'); $key_public = encryption::key_public_get('my-key'); //-------------------------------------------------- // 2. Encrypt $message = 'Hello'; // $encrypted = encryption::encode($message, 'my-key', 'sign'); $encrypted = 'Not supported'; //-------------------------------------------------- // 3. Decrypt // $decrypted = encryption::decode($encrypted, $key_public); $decrypted = $encrypted; //-------------------------------------------------- // Results echo debug_dump([ $key_public, $encrypted, $decrypted, ]); ?>

Back