default.inc in Encrypt 7.2
File
plugins/encryption_methods/default.inc
View source
<?php
$plugin = encrypt_default_encrypt_encryption_methods();
function encrypt_default_encrypt_encryption_methods() {
return array(
'title' => t('Basic'),
'description' => t('This is the basic default encryption type that does not require any special extensions.'),
'encrypt callback' => 'encrypt_encryption_methods_basic',
'deprecated' => TRUE,
);
}
function encrypt_encryption_methods_basic($op, $text, $key, $options = array()) {
$processed_text = '';
$text_length = strlen($text);
$key_length = strlen($key);
for ($i = 0; $i < $text_length; $i++) {
$char = substr($text, $i, 1);
$keychar = substr($key, $i % $key_length - 1, 1);
if ($op == 'decrypt') {
$char = chr(ord($char) - ord($keychar));
}
else {
$char = chr(ord($char) + ord($keychar));
}
$processed_text .= $char;
}
return $processed_text;
}