mako\crypto\OpenSSL


Description


OpenSSL cryptography adapter.


Class methods


Toggle source

public __construct($config)


Constructor.


Parameters

Type Description
array Configuration
Return value

NULL

public function __construct(array $config)
{
	if(extension_loaded('openssl') === false)
	{
		throw new RuntimeException(vsprintf("%s(): OpenSSL is not available.", array(__METHOD__)));
	}
	
	$this->key      = $config['key'];
	$this->cipher   = $config['cipher'];
}

Toggle source

public encrypt($string)


Encrypts data.


Parameters

Type Description
string String to encrypt
Return value

string

public function encrypt($string)
{
	return openssl_encrypt($string, $this->cipher, $this->key);
}

Toggle source

public decrypt($string)


Decrypts data.


Parameters

Type Description
string String to decrypt
Return value

string

public function decrypt($string)
{
	return openssl_decrypt($string, $this->cipher, $this->key);
}