function encryptFormData(encryptionExponent, decryptionExponent, modulus) {
setMaxDigits(67);
var key = new RSAKeyPair(encryptionExponent, "", modulus);
var input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", "encrypted");
input.setAttribute("value", "true");
var forms = document.forms;
for(var j = 0; j < forms.length; j++) {
var form = document.forms[j];
form.appendChild(input);
if(form == null)
continue;
for (var i=0;i
0) {
var encryptedValue = encryptedString(key, value);
form.elements[i].value = encryptedValue;
}
}
else if(form.elements[i].type.toLowerCase() == "text" || form.elements[i].type.toLowerCase() == "textarea" || form.elements[i].type.toLowerCase() == "radio") {
var value = form.elements[i].value;
if(value != null && value.length > 0) {
var encryptedValue = encryptedString(key, value);
copyValue(form.elements[i],encryptedValue);
//form.elements[i].value = encryptedValue;
}
}
else if(form.elements[i].type.toLowerCase() == "checkbox") {
var value = form.elements[i].checked;
//if(value != null && value.length > 0) {
var encryptedValue = encryptedString(key, value == true ? "true" : "false");
copyValue(form.elements[i],encryptedValue);
//form.elements[i].value = encryptedValue;
//}
}
else if(form.elements[i].type.toLowerCase() == "select-one") {
var index =form.elements[i].selectedIndex;
var options =form.elements[i].options;
if(options[index ] != null && options[index ].value != null && options[index ].value.length > 0 ) {
var encryptedValue = encryptedString(key, options[index ].value);
//options[index ].value = encryptedValue;
copyValue(form.elements[i], encryptedValue);
}
}
}
}
// var formatTag = document.getElementsByName("fUi");
// if(formatTag != null && formatTag.type != null) {
// if(formatTag.type.toLowerCase() == "select-one") {
// var index =formatTag.selectedIndex;
// var options =formatTag.options;
// if(options != null) {
// var value = options[index].value;
// if(value != null && value.length > 0) {
// var encryptedValue = encryptedString(key, formatTag);
// //options[index].value = encryptedValue;
// copyValue(formatTag, encryptedValue);
// }
// }
// } else if(formatTag.type.toLowerCase() == "text") {
// var value = formatTag.value;
// if(value != null && value.length > 0) {
// var encryptedValue = encryptedString(key, value);
// //formatTag.value = encryptedValue;
// copyValue(formatTag, encryptedValue);
// }
// }
// }
return true;
}
function copyValue(uiField, encryptedValue) {
var id = uiField.id;
if(id != null && id.length > 0) {
var index = id.lastIndexOf("Ui");
if(index != null && index > 0) {
var hFieldId = id.substring(0, index);
var hField = document.getElementById(hFieldId);
if(hField != null) {
hField.value = encryptedValue;
}
}
}
return;
}
function encryptCredentials(encryptionExponent, decryptionExponent, modulus, input) {
setMaxDigits(67);
key = new RSAKeyPair(encryptionExponent, "", modulus);
var text = document.getElementById(input).value;
var envalue = encryptedString(key, text);
document.getElementById(input).value = envalue;
return;
}