String text = browser.selectedText();
if (text.trim().equalsIgnoreCase(""))
return;
text = new String(text.replaceAll("\n", "<br/>"));
EnCryptDialog dialog = new EnCryptDialog();
dialog.exec();
if (!dialog.okPressed()) {
return;
}
EnCrypt crypt = new EnCrypt();
String encrypted = crypt.encrypt(text, dialog.getPassword().trim(), 64);
String decrypted = crypt.decrypt(encrypted, dialog.getPassword().trim(), 64);
if (encrypted.trim().equals("")) {
QMessageBox.information(this, tr("Error"), tr("Error Encrypting String"));
return;
}
StringBuffer buffer = new StringBuffer(encrypted.length() + 100);
buffer.append("<img en-tag=\"en-crypt\" cipher=\"RC2\" hint=\""
+ dialog.getHint().replace("'","\\'") + "\" length=\"64\" ");
buffer.append("contentEditable=\"false\" alt=\"");
buffer.append(encrypted);
buffer.append("\" src=\"").append(FileUtils.toForwardSlashedPath(Global.getFileManager().getImageDirPath("encrypt.png") +"\""));
Global.cryptCounter++;
buffer.append(" id=\"crypt"+Global.cryptCounter.toString() +"\"");
buffer.append(" onMouseOver=\"style.cursor=\\'hand\\'\"");
buffer.append(" onClick=\"window.jambi.decryptText(\\'crypt"+Global.cryptCounter.toString()
+"\\', \\'"+encrypted+"\\', \\'"+dialog.getHint().replace("'", "\\&apos;")+"\\');\"");
buffer.append("style=\"display:block\" />");
String script_start = new String(
"document.execCommand('insertHtml', false, '");
String script_end = new String("');");