Skip to content

Instantly share code, notes, and snippets.

@stvnrlnd
Created April 1, 2019 19:43
Show Gist options
  • Save stvnrlnd/1acdcc85c6a942cf62976026e0a6e1a2 to your computer and use it in GitHub Desktop.
Save stvnrlnd/1acdcc85c6a942cf62976026e0a6e1a2 to your computer and use it in GitHub Desktop.
public function encodeToken($string)
{
return base64_encode(openssl_encrypt($string, $this->encrypt_method, hash('sha256', $this->secret), 0, substr(hash( 'sha256', $this->initialization_vector ), 0, 16)));
}
public function decodeToken($string)
{
return openssl_decrypt(base64_decode($string), $this->encrypt_method, hash('sha256', $this->secret), 0, substr(hash('sha256', $this->initialization_vector), 0, 16));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment