src/Twisto/Twisto.php
private function encrypt($data)
    {
        $bin_key = pack("H*", substr($this->secret_key, 8));
        $aes_key = substr($bin_key, 0, 16);
        $salt = substr($bin_key, 16, 16);
        $iv = openssl_random_pseudo_bytes(16);
        $encrypted = openssl_encrypt($data, 'aes-128-cbc', $aes_key, true, $iv);
        $digest = hash_hmac('sha256', $data . $iv, $salt, true);
        return base64_encode($iv . $digest . $encrypted);
    }
private function encrypt($data)
    {
        $bin_key = pack("H*", substr($this->secret_key, 8));
        $aes_key = substr($bin_key, 0, 16);
        $salt = substr($bin_key, 16, 16);
        $iv = openssl_random_pseudo_bytes(16);
        $encrypted = openssl_encrypt($data, 'aes-128-cbc', $aes_key, true, $iv);
        $digest = hash_hmac('sha256', $data . $iv, $salt, true);
        return base64_encode($iv . $digest . $encrypted);
    }
private function encrypt ( $ data ) { $ bin_key = pack ( "H*" , substr ( $ this -> secret_key , 8 ) ) ; $ aes_key = substr ( $ bin_key , 0 , 16 ) ; $ salt = substr ( $ bin_key , 16 , 16 ) ; $ iv = openssl_random_pseudo_bytes ( 16 ) ; $ encrypted = openssl_encrypt ( $ data , 'aes-128-cbc' , $ aes_key , true , $ iv ) ; $ digest = hash_hmac ( 'sha256' , $ data . $ iv , $ salt , true ) ; return base64_encode ( $ iv . $ digest . $ encrypted ) ; }
Encrypt data with AES-128-CBC and HMAC-SHA-256
@param string $data
@return string
Encrypt data with AES - 128 - CBC and HMAC - SHA - 256