Skip to content

Commit

Permalink
rfe #954 Allow SALT in ENCRYPT function
Browse files Browse the repository at this point in the history
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
  • Loading branch information
madhuracj committed Feb 2, 2015
1 parent 2607b66 commit be237a7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -28,6 +28,7 @@ phpMyAdmin - ChangeLog
+ rfe #1596 Make "Options > Relational" configurable
+ rfe #719 More details in PDF relation view
+ rfe #1096 Cannot enter connection for federated engine table
+ rfe #954 Allow SALT in ENCRYPT function

4.3.9.0 (not yet released)
- bug #4728 Incorrect headings in routine editor
Expand Down
32 changes: 24 additions & 8 deletions js/tbl_change.js
Expand Up @@ -163,26 +163,34 @@ function verificationsAfterFieldChange(urlField, multi_edit, theType)
var new_salt_box = "<br><input type=text name=salt[multi_edit][" + multi_edit + "][" + urlField + "]" +
" id=salt_" + target.id + " placeholder='" + PMA_messages.strEncryptionKey + "'>";

//If AES_ENCRYPT is Selected then append the new textbox for salt
if (target.value === 'AES_DECRYPT' || target.value === 'AES_ENCRYPT') {
//If encrypting or decrypting functions that take salt as input is selected append the new textbox for salt
if (target.value === 'AES_ENCRYPT' ||
target.value === 'AES_DECRYPT' ||
target.value === 'DES_ENCRYPT' ||
target.value === 'DES_DECRYPT' ||
target.value === 'ENCRYPT') {
if (!($("#salt_" + target.id).length)) {
$this_input.after(new_salt_box);
}
} else {
//Remove the textbox for salt
$('#salt_' + target.id).prev('br').remove();
$("#salt_" + target.id).remove();
}

if (target.value === 'AES_DECRYPT' || target.value === 'AES_ENCRYPT') {
if ($this_input.data('type') !== 'HEX') {
$('#' + target.id).addClass('invalid_value');
return false;
}
} else if(target.value === 'MD5' &&
typeof $this_input.data('maxlength') !== 'undefined' &&
$this_input.data('maxlength') < 32
){
) {
$('#' + target.id).addClass('invalid_value');
return false;
} else {
$('#' + target.id).removeClass('invalid_value');
//The value of the select is no longer AES_ENCRYPT, remove the textbox for salt
$('#salt_' + target.id).prev('br').remove();
$("#salt_" + target.id).remove();
}

// Unchecks the corresponding "NULL" control
Expand Down Expand Up @@ -297,7 +305,11 @@ function applyFunctionToAllRows(currId, functionName, copySalt, salt, targetRows
}).attr("selected","selected");

// Handle salt field.
if (functionName === 'AES_ENCRYPT' || functionName === 'AES_DECRYPT') {
if (functionName === 'AES_ENCRYPT' ||
functionName === 'AES_DECRYPT' ||
functionName === 'DES_ENCRYPT' ||
functionName === 'DES_DECRYPT' ||
functionName === 'ENCRYPT') {
if ($("#salt_" + targetSelectList.attr("id")).length === 0) {
// Get hash value.
var hashed_value = targetSelectList.attr("name").match(/\[multi\_edit\]\[\d\]\[(.*)\]/);
Expand Down Expand Up @@ -655,7 +667,11 @@ AJAX.registerOnload('tbl_change.js', function () {
var salt;
var copySalt = false;

if (functionName === 'AES_ENCRYPT' || functionName === 'AES_DECRYPT') {
if (functionName === 'AES_ENCRYPT' ||
functionName === 'AES_DECRYPT' ||
functionName === 'DES_ENCRYPT' ||
functionName === 'DES_DECRYPT' ||
functionName === 'ENCRYPT') {
// Dialog title.
var title = functionName;
// Dialog buttons functions.
Expand Down
8 changes: 6 additions & 2 deletions libraries/insert_edit.lib.php
Expand Up @@ -2160,9 +2160,13 @@ function PMA_getCurrentValueAsAnArrayForMultipleEdit( $multi_edit_funcs,
|| ($current_value != "''"
&& in_array($multi_edit_funcs[$key], $func_optional_param))
) {
if (isset($multi_edit_salt[$key])
if ((isset($multi_edit_salt[$key])
&& ($multi_edit_funcs[$key] == "AES_ENCRYPT"
|| $multi_edit_funcs[$key] == "AES_DECRYPT")
|| $multi_edit_funcs[$key] == "AES_DECRYPT"))
|| (! empty($multi_edit_salt[$key])
&& ($multi_edit_funcs[$key] == "DES_ENCRYPT"
|| $multi_edit_funcs[$key] == "DES_DECRYPT"
|| $multi_edit_funcs[$key] == "ENCRYPT"))
) {
return $multi_edit_funcs[$key] . '(' . $current_value . ",'"
. PMA_Util::sqlAddSlashes($multi_edit_salt[$key]) . "')";
Expand Down

0 comments on commit be237a7

Please sign in to comment.