Jump to content

Recognizing File Type


 Share

Recommended Posts

I'm working on my little script which is dedicated to crypt/decrytp files. (i know there are other but i just want to improve myself with challenges...)

So i've handled other things so far i got one problem,

When i crypted a file with my script (using crytp.au3 functions- thx for that!) also i'm changing its extension to -lets say- ".crypt"

so when i wantto decrypt this file i would like to change it's extension to what it was before...

Is there anyway to recognize files' extension with autoit,

or can i add some data to my new ".crypt" extensioned file it's original extension. and then read it when i'm decrypting it...

Waiting for your answers.. thank you..

(my english is bad i know, and i'm sory.)

Link to comment
Share on other sites

#Include <Crypt.au3>  
$sPassword = "DarkAngel"  
$sSourceFile = "Filename.Ext" 
$sCryptFile = $sSourceFile & ".drk" 
$sDecryptFile = StringReplace($sCryptFile, ".drk", "")  
_Crypt_EncryptFile($sSourceFile, $sCryptFile, $sPassword, $CALG_DES)  
FileDelete($sSourceFile)  
MsgBox(0, "Check", "See if source has gone")  
_Crypt_DecryptFile($sCryptFile, $sDecryptFile, $sPassword, $CALG_DES)  
MsgBox(0, "Check", "See if the source is back again!")

;)

Hope this helps .. :)

Link to comment
Share on other sites

Thank both of you for your answers. Example and idea should work.

BUT

i don't know if i'm asking for too much but in this way file's original extension is obvious and script will create disturbing filenames like filename.avi.crypt etc.

So is there anyone know do that hidden. Or i will just use replace method...

Link to comment
Share on other sites

still wont work with all computers.

I'm thinking of adding resources as text in those files but don't have any idea to do that ...

Say you have a file called hello.txt containing text "Hello world". You can put the extension before the text "Hello World" and encrypt it like that. So you get ".txt|Hello World" and encrypt it into "asjkd896ad58asd" (random). You store the encrypted file as hello.crypt, once you decrypt and see the result ".txt|Hello World" you can remove the ".txt|" part and rename the file back to hello.txt.
Link to comment
Share on other sites

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...