June 26, 2015 at 3:25 am #20215
Stefan
Participant
Something like this I had in mind:
Encrypt-Encryption.jsee v0.01
//Encrypt-Encryption.jsee v0.01 - EmEditor 15 - 2015-06-26 by Stefan
WshFSO = new ActiveXObject( "Scripting.FileSystemObject" );
strFullName = document.FullName;
if(strFullName==""){
alert("Sorry, we don't work on non-existent document.\nPlease save it first.\n\nScript quits here.");
quit();
}
if (!document.Saved){
alert("Sorry, we don't work on un-saved document.\nPlease save it first.\n\nScript quits here.");
quit();
}
strPath = fPathName(document.FullName);
strName = document.Name;
strBase = fBaseName(strName);
strExte = fNameExte(strName);
strPaBa = strPath+"\\"+strBase;
strNewName = strPath+ "\\" + strBase + "_Backup." + strExte;
strEEFolder = fPathName(editor.FullName);
if(strExte=="EEE")
{
vUserAnswer = confirm("*.EEE file detected. Already encrypted? Encrypt it again?");
if(!vUserAnswer) quit();
}
strEncryptionName = strFullName + ".EEE";
strEncryptionName = prompt("Save encrypted file as:", strEncryptionName);
if(!strEncryptionName) quit();
if(WshFSO.FileExists(strEncryptionName))
{
vUserAnswer = confirm("Already existend. Overwrite?\n\n"+strEncryptionName);
if(!vUserAnswer) quit();
}
/*
Need thirs-party utility:
MySecret Blowfish Encryption Utility - Version 3.1.1 Released 9 June 2007.
Freeware command-line encryption utility - http://www.di-mgt.com.au/mysecret.html
Copyright (C) 2002-7 DI Management Services Pty Limited ABN 78 083 210 584
Sydney, Australia. www.di-mgt.com.au. All rights reserved.
*/
//MySecret -e -p "my pass phrase" -i infile -o outfile //-e|-d force Encrypt/Decrypt
pwd = prompt("Pass phrase to encrypt:","");
if(!pwd) quit();
cmd = strEEFolder + "\\Tools\\MySecret.exe -e -p " + pwd;
cmd = cmd + " -i " + strFullName + " -o " + strEncryptionName;
WshShell = new ActiveXObject( "WScript.Shell" );
WshShell.Run(cmd);
sleep(500);
if(WshFSO.FileExists(strEncryptionName)) {
editor.NewFile();
//document.close(); //close current plain file
editor.OpenFile( strEncryptionName );
}else{alert("Error. "+strEncryptionName+" not found." );}
//--------------------------------
function fPathName(str)
{
if(str.lastIndexOf("\\") != -1)
path = str.substring(0, str.lastIndexOf("\\"));
return path;
}
function fBaseName(str)
{
if(str.lastIndexOf(".") != -1)
base = str.substring(0, str.lastIndexOf("."));
return base;
}
function fNameExte(str)
{
if(str.lastIndexOf(".") != -1)
exten = str.substring(str.lastIndexOf(".")+1);
return exten;
}