objC = CreateObject("java","net.boncode.crypto.PGPController");
//set options
objC.setPrivatePath(Arguments.privatePath);
objC.setPublicPath(Arguments.publicPath);
objC.setKeyIdentity(Arguments.keyID);
objC.setKeyLength(Arguments.keyLength);
objC.setKeyPassphrase(Arguments.passPhrase);
//call ring generation
strReturn=objC.fGenerateRings();
//set options
objC.setPrivatePath(Arguments.privatePath);
objC.setPublicPath(Arguments.publicPath);
objC.setKeyIdentity(Arguments.keyID);
objC.setKeyLength(Arguments.keyLength);
objC.setKeyPassphrase(Arguments.passPhrase);
//call key generation
strReturn=objC.fGenerateRSAKeys();
//check inputs
if (Not FileExists(Arguments.contentFile)) strReturn="The unencrypted file[#Arguments.contentFile#] could not be found.";
if (Not FileExists(Arguments.publicKeyPath)) strReturn="The public key file[#Arguments.publicKeyPath#] could not be found.";
//interact with java
if (strReturn IS "") {
//set options
objC.setPublicPath(Arguments.publicKeyPath);
objC.setContentFile(Arguments.contentFile);
objC.setTargetFile(Arguments.targetFile);
//call encryption
strReturn=objC.fEncryptSimpleFile();
};
//check inputs
if (Not FileExists(Arguments.contentFile)) strReturn="The encrypted file[#Arguments.contentFile#] could not be found.";
if (Not FileExists(Arguments.privateKeyPath)) strReturn="The private key file[#Arguments.privateKeyPath#] could not be found.";
//interact with java
if (strReturn IS "") {
//set options
objC.setPrivatePath(Arguments.privateKeyPath);
objC.setContentFile(Arguments.contentFile);
objC.setKeyPassphrase(Arguments.keyPassPhrase);
objC.setTargetFile(Arguments.targetFile);
//call decryption
strReturn=objC.fDecryptSimpleFile();
//if we have a missing target file and no error, we have the wrong passphrase
if (NOT IsDefined("strReturn") OR IsDefined("strReturn") AND strReturn IS "" AND Arguments.targetFile NEQ "" AND Not FileExists(Arguments.targetFile)) {
strReturn="File could not be decrypted, please check your private key pass phrase.";
}
};
//check inputs
if (Not FileExists(Arguments.contentFile)) strReturn="The plain file [#Arguments.contentFile#] could not be found.";
if (Not FileExists(Arguments.privateKeyPath)) strReturn="The private key file [#Arguments.privateKeyPath#] could not be found.";
if (Not FileExists(Arguments.publicKeyPath)) strReturn="The public key file [#Arguments.publicKeyPath#] could not be found.";
//interact with java
if (strReturn IS "") {
//set options
objC.setPrivatePath(JavaCast("string",Arguments.privateKeyPath));
objC.setContentFile(JavaCast("string",Arguments.contentFile));
objC.setKeyPassphrase(JavaCast("string",Arguments.keyPassPhrase));
objC.setTargetFile(JavaCast("string",Arguments.targetFile));
objC.setPublicPath(JavaCast("string",Arguments.publicKeyPath));
//call encryption
strReturn=objC.fEncryptOnePassSignature();
//if we have a missing target file and no error, we have the wrong passphrase
if (Not IsDefined("strReturn") OR strReturn IS "" AND Arguments.targetFile NEQ "" AND Not FileExists(Arguments.targetFile)) {
strReturn="File could not be encrypted and signed, please check your inputs including private key pass phrase.";
}
};
//check inputs
if (Not FileExists(Arguments.contentFile)) strReturn="The encrypted file[#Arguments.contentFile#] could not be found.";
if (Not FileExists(Arguments.privateKeyPath)) strReturn="The private key file[#Arguments.privateKeyPath#] could not be found.";
if (Not FileExists(Arguments.publicKeyPath)) strReturn="The public key file[#Arguments.publicKeyPath#] could not be found.";
//interact with java
if (strReturn IS "") {
//set options
objC.setPrivatePath(JavaCast("string",Arguments.privateKeyPath));
objC.setContentFile(JavaCast("string",Arguments.contentFile));
objC.setKeyPassphrase(JavaCast("string",Arguments.keyPassPhrase));
objC.setTargetFile(JavaCast("string",Arguments.targetFile));
objC.setPublicPath(JavaCast("string",Arguments.publicKeyPath));
//call decryption
strReturn=objC.fDecryptOnePassSignature();
//if we have a missing target file and no error, we have the wrong passphrase
if (Not IsDefined("strReturn") OR strReturn IS "" AND Arguments.targetFile NEQ "" AND Not FileExists(Arguments.targetFile)) {
strReturn="Generic Error. File could not be decrypted, please check your private key pass phrase.";
}
};