Creating SDA via command line, script, programmatically - PGP

This is a discussion on Creating SDA via command line, script, programmatically - PGP ; FYI http://community.wow.net/grt/nsdpgp.html NSDPGP3X.DLL v1.0 COM Wrapper for PGP 8 SDAs Freeware. Freely distributable. NSDPGP3X.DLL is a COM Wrapper to the Self Decrypting Archive (SDA) functions of PGP version 8. Its single method allows creation of a PGP SDA file from ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Creating SDA via command line, script, programmatically

  1. Creating SDA via command line, script, programmatically

    FYI

    http://community.wow.net/grt/nsdpgp.html

    NSDPGP3X.DLL v1.0
    COM Wrapper for PGP 8 SDAs
    Freeware. Freely distributable.

    NSDPGP3X.DLL is a COM Wrapper to the Self Decrypting Archive (SDA)
    functions of PGP version 8. Its single method allows creation of a
    PGP SDA file from a calling client written in Visual Basic, ASP,
    JScript, Visual C++, Delphi, MS Office VBA etc. or from the command
    line via CSCRIPT + Windows Scripting Host or other intermediary
    executable.


    --
    Gerard R Thomas
    Port of Spain, Trinidad and Tobago
    mailto:grt@wow.net mailto:grt@geocities.com
    PGP Key IDs: RSA:0x9DBCDE7D DH/DSS:0xFF7155A2

  2. Re: Creating SDA via command line, script, programmatically

    grt wrote in news:Xns93FAB54E15A33grt@130.133.1.4:
    > etc. or from the command line via CSCRIPT + Windows Scripting
    > Host or other intermediary executable.


    Here is a short guide to using the COM object from the command line
    to create a self extracting archive (SDA) file via WSH. The
    readme.txt file in the ZIP archive has examples using Visual Basic,
    the WSH GUI (via Explorer), Visual C++ and ASP.

    WSH (the Windows Scripting Host) is included in Windows 98 and
    later OSes (ME/2K/XP etc). NT4 and 95 users can download the
    "Windows Script 5.1" package from MS. WSH includes both WSCRIPT.EXE
    and CSCRIPT.EXE executables (for GUI and Console mode running of
    scripts).

    Here we use the command prompt window so CSCRIPT.EXE and a script
    file (Jscript) are needed.

    The object has a method with three parameters. Some parameters (e.g
    the passphrase) may be specified in the .JS or .VBS script itself
    or all may provided on the command line.

    We will pass all three parameters (list of files to process, the
    output file and the passphrase) via the command line.
    A delimiter character is needed and we arbitrarily choose the #
    character. The comma is used by the COM Object itself to delimit
    the input filenames.

    We have two files: jan.doc and feb.xls (located in the c:\data
    folder) that we wish to place inside a SDA called january.sda.exe
    in the c:\upload folder.

    We specify the files by their full pathnames, each filename
    separated by commas

    The filelist is
    c:\data\jan.doc,c:\data\feb.xls

    The output file is
    c:\upload\january.sda.exe

    The passphrase is
    my secret

    Here is the command line

    > echo c:\data\jan.doc,c:\data\feb.xls#c:\upload\january. sda.exe#my

    secret | cscript /B sda.js


    The redirected echo sends the parameter list to the CSCRIPT
    executable which invokes the script file SDA.JS
    The /B switch simply suppresses the banner text

    It is the script file which invokes the COM Object.
    The script has to process its standard input (the parameter list)
    and call the COM Object method. This creates the SDA file.

    Here is the script file SDA.JS. It is placed in a directory on the
    PATH. Hopefully the included comments // make the script easy to
    understand.


    // sda.js
    //
    // example command line usage:
    // >echo
    // c:\data\jan.doc,c:\data\feb.xls#c:\upload\january. sda.exe#my
    // secret | cscript /B sda.js

    // variables

    var line, work, loc1, loc2, regexp;
    var filelist, outfile, password;

    // first we read in from standard input

    line = WScript.StdIn.ReadLine();

    // we use the # character to delimit the list of comma
    // delimited input files
    // from the output SDA filename and the passphrase
    // example:
    // c:\data\jan.doc,c:\data\feb.xls#c:\upload\january. sda.exe#my
    // secret
    //
    // we use regular expression: /pattern/flags
    // so pattern = # and flags = i (ignore case)


    regexp = /#/i;

    //find locations of the # characters

    loc1 = line.search(regexp);
    work = line.slice(loc1+1);
    loc2 = work.search(regexp);

    // cut the string into pieces
    // the +"" ensures proper termination of the strings we pass
    // to the COM object

    filelist = line.slice(0,loc1)+"";
    password = work.slice(loc2+1)+"";
    outfile = work.slice(0,loc2)+"";

    // we output result strings to standard output to check all is well
    // the +"\n" causes each to be output on a new line

    WScript.StdOut.Write(filelist+"\n");
    WScript.StdOut.Write(outfile+"\n");
    WScript.StdOut.Write(password+"\n");

    //instantiate the COM object

    pgpobj = WScript.CreateObject("Nsdpgp3xLib.SDA");

    //invoke the method to create the SDA file
    //the try...catch block allows error information from the DLL
    // to be obtained


    try{
    pgpobj.MakeSDA(filelist, outfile, password);
    }
    catch(err)
    {
    WScript.StdOut.Write(err.description+"\n");
    }

    // end of file


    --
    Gerard R Thomas
    Port of Spain, Trinidad and Tobago
    mailto:grt@wow.net mailto:grt@geocities.com
    PGP Key IDs: RSA:0x9DBCDE7D DH/DSS:0xFF7155A2

+ Reply to Thread