Jump to content

Encrypt a single file for upload...


Recommended Posts

I am working on a script. I thought I had already gotten a program to do what I need, but as it turns out when I went to install I figured out what the program really was. :) I really need to get ahold of a program that can in short encrypt a single file with a password of my choosing... I dont know maybe this can be done in AutoIt (if so please point me in the right direction) if not, then maybe a 3rd party program.

Let me know if you have anything I have tried googling for a long long time now... All I get is container programs. :)

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Thanks ezzetabi. I didnt think anyone would have asked since it isnt quite AutoIt related.

:)

Oh well that teaches me I should search next time! :)

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I am not sure IDEA can encrypt .PDF files. I have only had luck using it to encrypt .TXT files. If you are able to get it to work, then great! However, when I need to encrypt a file, I use zip.exe and zipcloak.exe to zip it and then encrypt the zip file. Both files are console-based so you can run them using (@ComSpec,"",@SW_Hide) to hide what you are inputting.

Here is a link to the files: InfoZip

You will want to download "zcr23xN.zip" to get zipcloak.exe along with zip.exe.

edit: corrected file name

Edited by SerialKiller
Link to comment
Share on other sites

Just as a note... does this program allow the file to just be decrypted without having to have the program?

I just found a program AxCrypt that I think will do what I want. It will take the non secure .pdf documents and turn them in to encrypted/self decrypting .exe's I just have to figure out the command line for it.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I like some problems more than others. This is one of them. :)

So I post here my solution:

Copy the idea.com file (with this name) in the script folder and enjoy.

;Important!  Important!  Important!
Dim $sCompiler = 'C:\Program Files\AutoIt3\Aut2Exe\Aut2Exe.exe';Put the right value here!
;Important!  Important!  Important!


Dim $sFile, $sShortName, $sPass1 = 'a', $sPass2 = 'b', $sPath, $iHandle, $bMode

$sFile = FileOpenDialog('Select the file you want to encrypt',@HomeDrive,'All (*.*)',1)

While Not ($sPass1 == $sPass2)
   $sPass1 = InputBox('Password 1','Put the password, max 128 chars','','-')
   If @error Then Exit
   $sPass2 = InputBox('Password 2','Confirm the password.','','-')
   If @error Then Exit
   If Not ($sPass1 == $sPass2) Then MsgBox(4096+32,'Problem','The passwords do not match.' & @lf & 'Restarting.')
Wend

$sShortName = FileGetShortName($sFile)
$sPath = StringLeft($sFile, StringInStr($sFile, '\', 0, -1))
$sFile = StringTrimLeft($sFile, StringInStr($sFile, '\', 0, -1))
$bMode = "+"
RunWait(@comspec & ' /c echo ' & $sPass1 & '|"' & $sIdeaPath & '" ' & $bMode & ' ' & $sShortName,'',@sw_hide)

$iHandle = FileOpen($sPath & '\~temp.au3',2)
FileWrite($iHandle,_
"FileInstall('" & $sIdeaPath & "' , @Tempdir & '\~~idea.com',1)" & @CRLF & _
"$sPass = InputBox('Password','Put the decrypt password','','-')" & @CRLF & _
"FileInstall('" & $sFile & "' , @WorkingDir & '\"& $sFile &"',1)" & @CRLF & _
"If StringRight(@WorkingDir,1) = '\' Then" & @CRLF & _
"$sShortName = FileGetShortName(@WorkingDir & '" & $sFile &"')" & @CRLF & _
"Else" & @CRLF & _
"$sShortName = FileGetShortName(@WorkingDir & '\" & $sFile &"')" & @CRLF & _
"EndIf" & @CRLF & _
"$bMode = '-'" & @CRLF & _
"RunWait(@comspec & ' /c echo ' & $sPass & '|""' & @Tempdir & '\~~idea.com"" ' & $bMode & ' ' & $sShortName,'',@sw_hide)" & @CRLF & _
"FileDelete(@Tempdir & '\~~idea.com')"  )
FileClose($iHandle)


RunWait('"' & $sCompiler & '" /in "' & $sPath & '~temp.au3" /comp 4 /nodecompile')
FileDelete($sPath & '~temp.au3')
FileDelete($sPath & $sFile)

FileMove($sPath & '~temp.exe',$sPath & $sFile & '.crypted.exe' )

Exit
Func OnAutoItExit()
   FileDelete(@Tempdir & '\~idea.com')
EndFunc

Func OnAutoItStart()
   Opt("MustDeclareVars", 1)
   Global $sIdeaPath
   FileInstall('idea.com',@Tempdir & '\~idea.com',1)
   $sIdeaPath = @Tempdir & '\~idea.com'
EndFunc

Edit:

As you can see (it is not too easy, but you should have no problems) the file is crypted, a .au3 file is created 'on-the-fly' with the crypted file and IDEA.COM itself and it is compiled.

Executing this new .exe file will ask for a password, no checks are made, just the idea algorith is applied. If the pass where correct you'll have your file with the original name in the current folder (the folder where the .exe is) otherwise you have a useless sequence of bits, but THE FILENAME IS PRESERVED! So if you need to mask it too, please rename it before. :)

Edit2: The SerialKiller comment about IDEA is crazy, idea.com can crypt every kind of file.

Edit3: JS, if you really need we can try to implement an other crypting on the filename, of course it will be much weaker than the IDEA one, but for only the filename should be ok.

Edited by ezzetabi
Link to comment
Share on other sites

oooo interesting... very nice. I may very well go with that option... ::goes and gets idea.com::

Edit: Can this do more than one file at a time with same password, but different .exe?

JS

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

The topic title is :

Encrypt a single file for upload...

But this is why Autoit is great, if you need something, just make it!

;Important!  Important!  Important!
Dim $sCompiler = 'C:\Program Files\AutoIt3\Aut2Exe\Aut2Exe.exe';Put the right value here!
;Important!  Important!  Important!


Dim $sFile, $aFile, $sShortName, $sPass1 = 'a', $sPass2 = 'b', $sPath, $iHandle, $bMode, $c

$sFile = FileOpenDialog('Select the file you want to encrypt', @HomeDrive, 'All (*.*)', 5)
If StringInStr($sFile, '|') Then;the user select more than one file.
   $aFile = StringSplit($sFile, '|')
Else;The user selected only a file.
   Dim $aFile[3]
   $aFile[0] = 2
   $aFile[1] = StringLeft($sFile, StringInStr($sFile, '\', 0, -1) - 1)
   $aFile[2] = StringTrimLeft($sFile, StringInStr($sFile, '\', 0, -1))
EndIf

While Not ($sPass1 == $sPass2)
   $sPass1 = InputBox('Password 1', 'Put the password, max 128 chars', '', '-')
   If @error Then Exit
   $sPass2 = InputBox('Password 2', 'Confirm the password.', '', '-')
   If @error Then Exit
   If Not ($sPass1 == $sPass2) Then MsgBox(4096 + 32, 'Problem', 'The passwords do not match.' & @LF & 'Restarting.')
Wend

$sPath = $aFile[1]
For $c = 2 To $aFile[0]
   $sShortName = FileGetShortName($aFile[$c])
   $sFile = $aFile[$c]
   
   $bMode = "+"
   RunWait(@ComSpec & ' /c echo ' & $sPass1 & '|"' & $sIdeaPath & '" ' & $bMode & ' ' & $sShortName, '', @SW_HIDE)
   
   $iHandle = FileOpen($sPath & '\~temp.au3', 2)
   FileWrite($iHandle, _
         "FileInstall('" & $sIdeaPath & "' , @Tempdir & '\~~idea.com',1)" & @CRLF & _
         "$sPass = InputBox('Password','Put the decrypt password','','-')" & @CRLF & _
         "FileInstall('" & $sFile & "' , @WorkingDir & '\" & $sFile & "',1)" & @CRLF & _
         "If StringRight(@WorkingDir,1) = '\' Then" & @CRLF & _
         "$sShortName = FileGetShortName(@WorkingDir & '" & $sFile & "')" & @CRLF & _
         "Else" & @CRLF & _
         "$sShortName = FileGetShortName(@WorkingDir & '\" & $sFile & "')" & @CRLF & _
         "EndIf" & @CRLF & _
         "$bMode = '-'" & @CRLF & _
         "RunWait(@comspec & ' /c echo ' & $sPass & '|""' & @Tempdir & '\~~idea.com"" ' & $bMode & ' ' & $sShortName,'',@sw_hide)" & @CRLF & _
         "FileDelete(@Tempdir & '\~~idea.com')")
   FileClose($iHandle)
   
   
   RunWait('"' & $sCompiler & '" /in "' & $sPath & '\~temp.au3" /comp 4 /nodecompile')
   FileDelete($sPath & '\~temp.au3')
   FileDelete($sPath & '\' & $sFile)
   
   FileMove($sPath & '\~temp.exe', $sPath & '\' & $sFile & '.crypted.exe')
Next

Exit
Func OnAutoItExit()
   FileDelete(@TempDir & '\~idea.com')
EndFunc  ;==>OnAutoItExit

Func OnAutoItStart()
   Opt("MustDeclareVars", 1)
   Global $sIdeaPath
   FileInstall('idea.com', @TempDir & '\~idea.com', 1)
   $sIdeaPath = @TempDir & '\~idea.com'
EndFunc  ;==>OnAutoItStart

Edit :) : I can maybe FileInstall Aut2Exe and promote this program. (joking, of course :)

Edited by ezzetabi
Link to comment
Share on other sites

I have to thank you JS.

With this system I solve also a problem of mine. You know, idea crypt 'on the place' and this is good. But I always feared that someone trying random passwords (for decripting) would corrupt the files!

This way intead the original, crypted, file is sure inside the compiled .exe and a wrong password will make a non working copy.

GREAT :)

Link to comment
Share on other sites

ezzetabi all I do now is follow your posts to get answers to questions I didnt know I had!!!

you could use lzarc (freeware) http://izsoft.cjb.net to compress your files (it has a nice command line) then use ezzetabi's program to encript the resulting zip file so that you'll have a smaller file.

I use cutepdf http://www.CutePDF.com to create pdf documents it is a free program

thanks.

Link to comment
Share on other sites

The .pdf documents are already created for me though I do like ezzetabi's code I am not sure which way I a going to go with this yet... I would prefer sticking as much to AutoIt as possible, but we shall see which one performs better to my needs... :-P

The program I am working with allows for multiple files.. the only thing I dont like is the fact it uses their icon and their encryption... I guess I should check out IDEA.com, but I dont have much time I have to get this done by this weekend, though I have to say if the person I am doing this for likes it enough I very well may be allowed more time to do some extra research.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I am not seeing where the following variable is defined... $sIdeaPath

Thanks,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

ezzetabi  all I do now is follow your posts to get answers to questions I didnt know I had!!!

Well... :"> I am happy.

you could use lzarc (freeware)    http://izsoft.cjb.net  to compress your files (it has a nice command line) then use ezzetabi's program to encript the resulting zip file so that you'll have a smaller file.

My script creates on the fly a .au3 file that fileinstall(), via compiling, the files. As you can see in the line:

RunWait('"' & $sCompiler & '" /in "' & $sPath & '\~temp.au3" /comp 4 /nodecompile')

/comp is set to 4 that should be the best.

I do not know how good is the Jon compression, but surely something will be done. :)

I use cutepdf  http://www.CutePDF.com  to create pdf documents it is a free program

thanks.

<{POST_SNAPBACK}>

CutePDF is nice, but think the best is PDF creator. But as JS said, he (she?) already have the .pdf files, so I didn't posted anything about this.
Link to comment
Share on other sites

  • 1 year later...
  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...