AutoHotkey Community

It is currently May 26th, 2012, 6:23 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 34 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: June 17th, 2005, 4:53 am 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
if the earlier is working fine then its not necessary to update. if u still want to, then make sure u follow the new procedure well. (var name is 'data', result is in 'result' & u gosub rc4b)

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2005, 5:06 pm 
Offline

Joined: May 4th, 2005, 7:07 pm
Posts: 16
I get it working after I run it the 1st time & save the password.

I load 1st gui encrypt password & save it 2 an *.ini file then when I load 2nd gui it decrypts the password & shows it decrypted but if I cancel then load 2nd Gui again it encrypts the password again or if I change the password, everytime I load 2nd Gui it continues encrypting it each time I load the gui. :oops:

Can't figure out what I'm doing wrong.I guess I'll just have 2 stick with the earlier version till I finally figure out where I messed up. :roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2005, 6:47 pm 
Offline

Joined: March 2nd, 2005, 10:59 am
Posts: 59
HEllo
How can we know whats wrong without knowing your code? :wink:
MIchael


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2005, 9:13 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
there's a small update to script. just the usage has been simplified.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2005, 2:39 am 
I just wanted to say that this code really helped me in a project I was working on. Thanks alot.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2005, 11:52 am 
The script as a function, for easy #inclusion:

Code:
RC4Pass = wow_he-really+is cool_!
RC4Data = Rajat is cool

RC4(RC4Data,RC4Pass)
MsgBox, Changed`n`n%RC4Data%`n`nwith pass:`n`n%RC4Pass%`n`nto`n`n%RC4Result%

RC4Data = %RC4Result%

RC4(RC4Data,RC4Pass)
MsgBox, Changed`n`n%RC4Data%`n`nwith pass:`n`n%RC4Pass%`n`nto`n`n%RC4Result%

ExitApp

;___RC4_____________________________________

RC4(RC4Data,RC4Pass)
{
   global RC4Result
   ATrim = %A_AutoTrim%
   AutoTrim, Off
   BLines = %A_BatchLines%
   SetBatchlines, -1
   StringLen, RC4PassLen, RC4Pass
   Loop, 256
   {
      a := A_Index - 1
      Transform, ModVal, Mod, %a%, %RC4PassLen%
      ModVal ++
      StringMid, C, RC4Pass, %ModVal%, 1
      Transform, AscVar, Asc, %C%
      Key%a% = %AscVar%
      sBox%a% = %a%
   }
   b = 0
   Loop, 256
   {
      a := A_Index - 1
      TempVar := b + sBox%a% + Key%a%
      Transform, b, Mod, %TempVar%, 256
      T := sBox%a%
      sBox%a% := sBox%b%
      sBox%b% = %T%
   }
   StringLen, DataLen, RC4Data
   RC4Result =
   i = 0
   j = 0
   Loop, %DataLen%
   {
      TmpVar := i + 1
      Transform, i, Mod, %TmpVar%, 256
      TmpVar := sBox%i% + j
      Transform, j, Mod, %TmpVar%, 256
      TmpVar := sBox%i% + sBox%j%
      Transform, TmpVar2, Mod, %TmpVar%, 256
      k := sBox%TmpVar2%
      StringMid, TmpVar, RC4Data, %A_Index%, 1
      Transform, AscVar, Asc, %TmpVar%
      Transform, C, BitXOR, %AscVar%, %k%
      IfEqual, C, 0
         C = %k%
      Transform, ChrVar, Chr, %C%
      RC4Result = %RC4Result%%ChrVar%
   }
AutoTrim, %ATrim%
SetBatchlines, %BLines%
Return RC4Result
}
;___RC4_____________________________________


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2005, 8:38 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
thanx for the function. the reason i didn't do so myself is that the first 2 loops are reqd only once for one pwd. so if you don't change the pwd but call the function several times for different data items then it does lots of unnecessary calculations, thus gets slower.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2005, 5:15 pm 
Offline

Joined: December 7th, 2005, 8:29 am
Posts: 345
Hi,

i did this script just to see how i can write encrypted passord to ini file and
restore it but somehow i can seem to make it....
can anyone help?

thanks
Twhyman

Code:
; Generated using SmartGUI Creator 3.5.1
IniRead, SUN, E:\Documents and Settings\admin\Desktop\test.ini, username, user ;Read User Name From ini
IniRead, SUP, E:\Documents and Settings\admin\Desktop\test.ini, pass, password ;Read Password From ini
Gui, Show, x182 y47 h149 w344, Password Encryption Test

Gui, Add, Text, x46 y37 w110 h20,User
Gui, Add, Edit, x176 y37 w130 h20 vGsUser, %SUN%
Gui, Add, Text, x46 y67 w110 h20,Password
Gui, Add, Edit, x176 y67 w130 h20 vGsPass, %SUP%
Gui, Add, Button, x126 y107 w110 h20 gSubmit,Submit
Return

Submit:
Gui, Submit, NoHide
GoSub RC4

PW = GsPass
Data = Rajat is cool

Gosub, RC4
MsgBox, %Result%

Data = %Result%

Gosub, RC4
MsgBox, %Result%


GuiClose:
IniWrite, %GsUser%, E:\Documents and Settings\admin\Desktop\test.ini, username, user ;Writes UserName to ini
IniWrite, %Result%, E:\Documents and Settings\admin\Desktop\test.ini, pass, password ;Writes Password to ini
ExitApp


;___RC4_____________________________________

RC4:
   ATrim = %A_AutoTrim%
   AutoTrim, Off
   BLines = %A_BatchLines%
   SetBatchlines, -1

   StringLen, PWLen, PW
   
   IfNotEqual, PW, %OldPW%
   {
      Loop, 256
      {
         a := A_Index - 1
         
         Transform, ModVal, Mod, %a%, %PWLen%
         ModVal ++
         
         StringMid, C, PW, %ModVal%, 1
         Transform, AscVar, Asc, %C%
   
         Key%a% = %AscVar%
         sBox%a% = %a%
      }
      
      b = 0
      Loop, 256
      {
         a := A_Index - 1
   
         TempVar := b + sBox%a% + Key%a%
         Transform, b, Mod, %TempVar%, 256
         
         T := sBox%a%
         sBox%a% := sBox%b%
         sBox%b% = %T%
      }
   
      OldPW = %PW%
   }

   StringLen, DataLen, Data
   
   Result =
   i = 0
   j = 0

   Loop, %DataLen%
   {
      TmpVar := i + 1
      Transform, i, Mod, %TmpVar%, 256

      TmpVar := sBox%i% + j
      Transform, j, Mod, %TmpVar%, 256

      TmpVar := sBox%i% + sBox%j%
      Transform, TmpVar2, Mod, %TmpVar%, 256
      
      k := sBox%TmpVar2%
      
      StringMid, TmpVar, Data, %A_Index%, 1
      Transform, AscVar, Asc, %TmpVar%

      Transform, C, BitXOR, %AscVar%, %k%

      IfEqual, C, 0
         C = %k%
      
      Transform, ChrVar, Chr, %C%

      Result = %Result%%ChrVar%
   }


   AutoTrim, %ATrim%
   SetBatchlines, %BLines%
Return

;___RC4_____________________________________


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2005, 9:22 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
There are problems with RC4 in binary mode: the encrypted text can contain non-printable characters. If you write them in a file and read back, different ones could map to the same character. If there is a NUL, it is treated as a string terminator, etc. If you insist on using RC4, you have to modify the code, such that the result is a stream of hex digits. But RC4 is not very secure, so why bother? Use instead TEA, the Tiny Encryption Algorithm. For texts use this, or that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 12th, 2006, 5:25 pm 
Offline

Joined: December 27th, 2005, 2:28 pm
Posts: 36
Im trying to crypt a file, 24.txt, and then save it as 24Crypt.txt. Then i want to decrypt it and save it as 24Decrypt.txt. I cant understand why the If(Data = Result) doesnt seems to be true.

Code:
PW = password

FileRead, Data, %A_WorkingDir%\24.txt

Gosub, RC4

Loop, Parse, Result, `n, `r

  FileAppend, %A_LoopField%`n, %A_WorkingDir%\24Crypt.txt
}
;-----------------------

FileRead, Data, %A_WorkingDir%\24Crypt.txt

StringTrimRight, Data, Data, 2  ;This line is supposed to take away the last line feed.

If (Data = Result) Then   
  MsgBox, They are exactly alike
MsgBox, %Data%
MsgBox, %Result%

;Data = %Result%    ;If I uncomment this it will work.
Gosub, RC4

Loop, Parse, Result, `n, `r

  FileAppend, %A_LoopField%`n, %A_WorkingDir%\24Decrypt.txt
}

ExitApp


;___RC4_____________________________________

RC4:
   ATrim = %A_AutoTrim%
   AutoTrim, Off
   BLines = %A_BatchLines%
   SetBatchlines, -1

   StringLen, PWLen, PW
   
   IfNotEqual, PW, %OldPW%
   {
      Loop, 256
      {
         a := A_Index - 1
         
         Transform, ModVal, Mod, %a%, %PWLen%
         ModVal ++
         
         StringMid, C, PW, %ModVal%, 1
         Transform, AscVar, Asc, %C%
   
         Key%a% = %AscVar%
         sBox%a% = %a%
      }
      
      b = 0
      Loop, 256
      {
         a := A_Index - 1
   
         TempVar := b + sBox%a% + Key%a%
         Transform, b, Mod, %TempVar%, 256
         
         T := sBox%a%
         sBox%a% := sBox%b%
         sBox%b% = %T%
      }
   
      OldPW = %PW%
   }

   StringLen, DataLen, Data
   
   Result =
   i = 0
   j = 0

   Loop, %DataLen%
   {
      TmpVar := i + 1
      Transform, i, Mod, %TmpVar%, 256

      TmpVar := sBox%i% + j
      Transform, j, Mod, %TmpVar%, 256

      TmpVar := sBox%i% + sBox%j%
      Transform, TmpVar2, Mod, %TmpVar%, 256
      
      k := sBox%TmpVar2%
      
      StringMid, TmpVar, Data, %A_Index%, 1
      Transform, AscVar, Asc, %TmpVar%

      Transform, C, BitXOR, %AscVar%, %k%

      IfEqual, C, 0
         C = %k%
      
      Transform, ChrVar, Chr, %C%

      Result = %Result%%ChrVar%
   }


   AutoTrim, %ATrim%
   SetBatchlines, %BLines%

Return

;___RC4_____________________________________


24.txt (Dont mind the text, just copied the post above)
Code:
There are problems with RC4 in binary mode: the encrypted text
can contain non-printable characters.
If you write them in a file and read back,
different ones could map to the same character.
If there is a NUL, it is treated as a string terminator, etc.
If you insist on using RC4, you have to modify the code,
such that the result is a stream of hex digits.
But RC4 is not very secure, so why bother?
Use instead TEA, the Tiny Encryption Algorithm.
For texts use this, or that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 12th, 2006, 5:38 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
As I said, this code fails if there is a NUL character in the ciphertext. Use instead the hex-stream version.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 12th, 2006, 6:49 pm 
Offline

Joined: December 27th, 2005, 2:28 pm
Posts: 36
Thank You! :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 12th, 2006, 7:17 pm 
Offline

Joined: July 6th, 2004, 10:07 am
Posts: 171
Location: Manchester, England.
Hi All

If anyone wants to do some serious encryption on very large binary et al, then maybe this is for you 'AESY.EXE'.


http://www.wzw.tum.de/~syring/win32/

Thanx
Dave.

_________________
Simple ideas lie within reach, only of complex minds


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 12th, 2006, 7:41 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Thanks, Dave! It works, fast, it is small, but I wish I could specify the output file. It just overwrites the original, (which is what you want most of the time). You cannot test the program on itself ("Couldn't open file with CreateFile()"). Error handling is not reliable: sometimes, if you attempt to encrypt a non-existent file, you would not know that it failed. ErrorLevel is still 0. I could not find out, which AES version it uses, how the key is converted to binary key, etc. Otherwise, it is a great little program.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2006, 9:12 pm 
Offline

Joined: July 6th, 2004, 10:07 am
Posts: 171
Location: Manchester, England.
Hi All,

@Laszlo

Bit late getting back to you on this sorry!.

1./ If you make a copy of aesy.exe somewhere else then you can encrypt it. Basically it checks to make sure you don't cut the branch your sitting on.
2./ The code below works for me in every situation so far encountered.

Code:
;; Win xp pro sp0
;; Ahk Version 1.0.43.08


RunWait, %comspec% /c aesy isExist.dat  , , min
   MsgBox %errorlevel%

;; returns 0

RunWait, %comspec% /c aesy noExist.dat  , , min
   MsgBox %errorlevel%

;; returns 1



3./ Now the really good stuff 8)

http://fp.gladman.plus.com/AES/index.htm

Enjoy !

Dave.

_________________
Simple ideas lie within reach, only of complex minds


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 34 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher, Jaaaaaaaaay and 8 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group