function drush_encrypt_encrypt in Encrypt 8.3
Encrypt text with the given encryption profile.
Parameters
string $encryption_profile_name: The encryption profile machine name.
string $text: The text to encrypt.
Return value
string The encrypted text.
File
- drush/
encrypt.drush.inc, line 92 - Drush integration for Encrypt module.
Code
function drush_encrypt_encrypt($encryption_profile_name = FALSE, $text = FALSE) {
if ($encryption_profile_name && $text) {
$service = \Drupal::service('encryption');
$encryption_profile = EncryptionProfile::load($encryption_profile_name);
if (!$encryption_profile) {
return drush_set_error('', dt('Encryption profile "@name" could not be loaded.', [
'@name' => $encryption_profile_name,
]));
}
else {
$encrypted_text = $service
->encrypt($text, $encryption_profile);
if (drush_get_option('base64')) {
$encrypted_text = base64_encode($encrypted_text);
}
drush_print($encrypted_text);
}
}
else {
return drush_set_error('error', dt('Please specify the encryption profile and the text to be encrypted', []));
}
}