class SystemStatusEncryption in System Status 7
Same name and namespace in other branches
- 6.2 system_status_encryption.inc \SystemStatusEncryption
@file Encryption logic for system_status
Hierarchy
- class \SystemStatusEncryption
Expanded class hierarchy of SystemStatusEncryption
File
- ./
system_status_encryption.inc, line 7 - Encryption logic for system_status
View source
class SystemStatusEncryption {
/**
* System Status: create a new token.
*/
public static function getToken() {
$chars = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'), range(0, 99));
shuffle($chars);
$token = "";
for ($i = 0; $i < 8; $i++) {
$token .= $chars[$i];
}
return $token;
}
/**
* System Status: encrypt a plaintext message.
*/
public static function encrypt($plaintext) {
$key = hash("SHA256", variable_get('system_status_encrypt_token', 'Error-no-token'), TRUE);
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$plaintext_utf8 = utf8_encode($plaintext);
$ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $plaintext_utf8, MCRYPT_MODE_CBC, $iv);
$ciphertext = $iv . $ciphertext;
return base64_encode($ciphertext);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SystemStatusEncryption:: |
public static | function | System Status: encrypt a plaintext message. | |
SystemStatusEncryption:: |
public static | function | System Status: create a new token. |