public function EncryptTest::testCheckEncryptionMethodsKeys in Encrypt 6
Test to check encryption methods
File
- ./
encrypt.test, line 35 - Tests for Encrypt.
Class
- EncryptTest
- Test Class for Encrypt
Code
public function testCheckEncryptionMethodsKeys() {
$test_strings = array(
'Test String',
'1234',
'123',
'111 00004 34 ls dlkj s lsjf sd <>?:"{})#(*#@&$@#^$!@@',
);
$options = array();
// Get methods
encrypt_initialize();
$methods = encrypt_get_methods('full');
// Get key names
$key_names = array(
NULL,
ENCRYPT_DEFAULT_KEY,
ENCRYPT_DEFAULT_KEY_FILE,
ENCRYPT_DEFAULT_KEY_DB,
);
// Go through strings, methods, and keys
foreach ($test_strings as $test_string) {
foreach ($key_names as $key_name) {
foreach ($methods as $method_name => $method) {
// Test that original string is the same as encrypting
// then decrypting
$processed = decrypt(encrypt($test_string, $options, $method_name, $key_name));
$this
->assertEqual($test_string, $processed, t('Ensure encryption works for method: %method and key_name: %key', array(
'%method' => $method['title'],
'%key' => $key_name,
)));
}
}
}
}