<?php class MyEncryption { public $pubkey = '123'; public $privkey = '123'; public function encrypt($data) { if (openssl_public_encrypt($data, $encrypted, $this->pubkey)) $data = base64_encode($encrypted); else throw new Exception('Unable to encrypt data. Perhaps it is bigger than the key size?'); return $data; } public function decrypt($data) { if (openssl_private_decrypt(base64_decode($data), $decrypted, $this->privkey)) $data = $decrypted; else $data = ''; return $data; } } $test=new MyEncryption(); echo $test->encrypt("grr"); ?>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)