Jump to content



Photo

File Encryption


  • Please log in to reply
23 replies to this topic

#1 steve8tch

steve8tch

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 288 posts

Posted 24 April 2005 - 11:05 PM

I know there have been many topics covering encryption - but most talk about encrpting string values. What I would like to see added to Aut3 is some basic encryption of files - just to prevent things like text files being viewed as straight text.

I was thinking that the fuctionality would be added as follows :-

FileOpen("filename",Mode,[password]) There would have to be 3 more "Mode values"
Mode 3 - Open Encrypted file for reading.
Mode 4 - Open/Create Encrypted file for writing.
Mode 5 - Open/Overwrite Encrypted file for writing.

I was not thinking some super delux 256 bit key pair here - for that we could file install an encrytion program and encrypt a File - but just enough to prevent casual viewing :) and a little bit of hacking. :D

Any thoughts....





#2 Insolence

Insolence

    Not distastefully arrogant

  • Active Members
  • PipPipPipPipPipPip
  • 1,304 posts

Posted 24 April 2005 - 11:06 PM

Sounds like something a UDF would be good for :)
"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

#3 b14ck

b14ck

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 379 posts

Posted 25 April 2005 - 03:57 AM

Maybe build in an md5 that can accept files, strings, or whatever else. Just overload it a lot :)
-I am the giver of life and the bringer of death.

#4 Insolence

Insolence

    Not distastefully arrogant

  • Active Members
  • PipPipPipPipPipPip
  • 1,304 posts

Posted 25 April 2005 - 04:08 AM

It seems you've been away a while Black, where were ya? (not being rude)

Sven, which has been doing a lot of great work lately, made a MD5 function in AutoIt. Think that'll work?

http://www.autoitscript.com/forum/index.php?showtopic=10590
"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

#5 MSLx Fanboy

MSLx Fanboy

    Local $Clue = 0

  • Active Members
  • PipPipPipPipPipPip
  • 1,046 posts

Posted 28 April 2005 - 01:15 AM

You can't decrypt an MD5 however. Why not just FileReadLine() and then _StringEncrypt()? That's a basic encryption, just create a function file to include, so that _FileEncrypt("somefile.txt", "password") will do that...

Some Psuedocode:

Func _FileEncrypt($filename, $passkey, $outfilename)

$infile = FileOpen($filename, r)
$outfile = FileOpen($outfilename, w)
While Not EOF
$text = FileReadLine($infile)
$entext = _StringEncrypt(1, $text, $passkey)

FileWrite($outfile, $entext)
WEnd
FileClose($infile)
FileClose($outfile)
EndFunc

Then just decrypt it to a string...


EndFunc
Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

#6 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,686 posts

Posted 15 May 2005 - 05:00 AM

I just created an encryption function of my own. It is a one way (it could be undone... but I didnt make the reverse as I dont want it reversed.) encryption, but very useful.

One other thing you might find useful is AxCrypt. Very good utility.
Link: AxCrypt Website

I hope that helps some. I will post my UDF in the Scripts and Scraps Forum.
JS
AutoIt LinksFile-String Hash Plugin Updated! 04-02-08ComputerGetInfo UDF's Updated! 11-23-06External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

#7 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 15 May 2005 - 05:16 AM

Microsoft has crypto functions that you can use via DllCall. I was looking it over and it can be done in autoit.
Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

#8 layer

layer

    i love skateboarding

  • Active Members
  • PipPipPipPipPipPip
  • 2,470 posts

Posted 16 May 2005 - 12:51 AM

Microsoft has crypto functions that you can use via DllCall.  I was looking it over and it can be done in autoit.

<{POST_SNAPBACK}>

Yea, I've seen those too :( They're called "FileEncrypt" ? Something simple like that, or vice versa, it was a while ago I've seen them... :(
FootbaG

#9 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 16 May 2005 - 01:58 AM

There are C examples,
Decrypting a file
and Encrypting a file
Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

#10 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 16 May 2005 - 05:05 AM

So I am pretty far along on implement a File encryption/decrypt UDF from the pervious links. Just incase someone else was trying to implement it too.
Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

#11 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 16 May 2005 - 06:37 AM

Ok, not ready for a UDF posting but I thought I would post this.

This is my test script, just create a file a.txt (mine just had 'test') and the a.decrypt.txt should be the same, and the file a.encrypted is encrypted.
#cs vi:ts=4 sw=4: Ejoc #ce #include <crypto.au3> Opt("MustDeclareVars",1) ;encrypt a.txt using the password test and save as a.encrypt _FileEncrypt("a.txt","a.encrypt","test") ;reverse it _FileDecrypt("a.encrypt","a.decrypt.txt","test")

Attached Files


Edited by Ejoc, 16 May 2005 - 06:37 AM.

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

#12 steve8tch

steve8tch

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 288 posts

Posted 16 May 2005 - 08:12 AM

Thanks Ejoc for your hard work here.
Thanks also for your brilliant contributions elsewhere in this community :(

I have tried the crypto.au3 - it works really well - this is going to be great for sending files around the place in a reasonably secure way.

but...

in order to work on the encrypted file - this encrypted file is decrpted to a plain text file - if a script were to crash before measures can be taken to delete that file - you could leave potentialy classified info around in plain text on a PC.

so...

is it possible to create an option to write the output directly to $var - this way decryted text would remain in memory rather than lying around as a plain text file.

Thanks again.


Oopps - one more question.
Your DllStruct.au3 UDF calls kernel32.dll. Does this exist on a Win98/ME PC? - I am just thinking about a file encrypted on one PC - trying to decrypt it on a different OS.

Thanks.

#13 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 16 May 2005 - 04:44 PM

I was already planning on encrypting $var to keep it in memory. I want to do alittle more reasearch on protected memory as keeping the information there would be much better.

Kernel32.dll goes back to win95
Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

#14 steve8tch

steve8tch

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 288 posts

Posted 16 May 2005 - 05:13 PM

Superb. :(
Thanks again for your time and effort.

#15 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 16 May 2005 - 08:50 PM

Ok UDF is: http://www.autoitscript.com/forum/index.php?showtopic=11513
Will need new version of DllStruct.AU3 for it.

#cs vi:ts=4 sw=4: Ejoc #ce #include <crypto.au3> Opt("MustDeclareVars",1) Global $s           = "This is a plain text line" Global $password    = "PASSWORD" Global $filename    = "encrypted.txt" Global $decrypted   = "" ;encrypt the string and write a new file If Not _EncryptStringToFile($s,$password,$filename) Then     MsgBox(0,"error","Error Encrypting")     exit EndIf $decrypted  = _DecryptFileToString($filename,$password) MsgBox(0,"decrypted",$decrypted)

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

#16 this-is-me

this-is-me

    Pursuer of obscure functionality

  • Active Members
  • PipPipPipPipPipPip
  • 2,372 posts

Posted 16 May 2005 - 09:10 PM

Does this md5 hashing work on win98?
Who else would I be?

#17 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 16 May 2005 - 09:14 PM

looks like it should, the crypto functions claim to be there from Windows 95 OSR2 and later
Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

#18 this-is-me

this-is-me

    Pursuer of obscure functionality

  • Active Members
  • PipPipPipPipPipPip
  • 2,372 posts

Posted 16 May 2005 - 09:19 PM

Thanks Ejoc.
Who else would I be?

#19 daff

daff

    Seeker

  • New Members
  • 1 posts

Posted 16 August 2006 - 06:50 AM

hello! im a student, i would like to ask for your help regarding our problem... our thesis, entitled Comparative study about Encryption Standards...i will be waiting for your suggestions about our thesis...

thank you very much.

God Bless you...!

#20 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,686 posts

Posted 16 August 2006 - 07:58 AM

hello! im a student, i would like to ask for your help regarding our problem... our thesis, entitled Comparative study about Encryption Standards...i will be waiting for your suggestions about our thesis...

thank you very much.

God Bless you...!


What encryption standards are you going to compare? There have been several mentioned in this topic. Another thing is this is a very old thread (1 year). I dont know that here in the AutoIt community anyone is here to help with homework.

Good Luck with the thesis paper.

Go to the first page and check my post. It has a link in it to an encryption software that compares several encryption methods.

JS
AutoIt LinksFile-String Hash Plugin Updated! 04-02-08ComputerGetInfo UDF's Updated! 11-23-06External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users