private function encrypt($value)
{
$this->checkKey();
$iv = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM);
$cipher = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->key, json_encode($value), 'ctr', $iv);
$hmac = hash_hmac('sha256', $iv . $cipher, $this->authentication, true);
return base64_encode($hmac . $iv . $cipher);
}