So I had a question about this AHK Script it's basically an encrypter and decrypter. If you run the program you will need to input a password first and then you get to the real program so if you input a string inside of there and "Encode" it is there any way you can Save the "Encoded" string into a .txt with just a button?
I tried some stuff I found on the Internet with Submit and so but i didn't really figure it out. So I am kinda stuck here!
SetBatchLines -1
StringCaseSense Off
AutoTrim Off
Hotkey, !x, Exit
InputBox, pass ,Encrypter 1.0, Please enter the Password , HIDE, 190, 140
ifEqual pass, pass, GoSub, key
IfNotEqual, pass, pass, MsgBox , 0, Wrong Password, The password was incorrect please try again or press "ESC" to Exit the Programm
IfNotEqual, pass, pass, Reload
Sleep, 100
;----------------Interface--------------
Gui, 1: Add, Edit, x10 y10 w280 r8 vEncDec
Gui, 1: Font, bold
Gui, 1: Add, Text,, Copy and paste your raw text here to encrypt it.
Gui, 1: Color, d80101
Gui, 1: Add, Button, x10 y150 w75 gENCRYPT, Encode
Gui, 1: Add, Button, x10 y178 w75 gDELETE, Delete
Gui, 1: Add, Button, x110 y150 w75 gDECRYPT, Decode
Gui, 1: Add, Button, x110 y178 w75 gOPEN, Save
Gui, 1: Add, Button, x215 y150 w75 gExit, Exit
Gui, 1: Add, Button, x215 y178 w75 gCREATE, Create
Gui, 1: Show, w300 h208, Encrypter v1.0
Return
;------------------MANAGMENT---------------
DELETE:
MsgBox, 262208, WARNING!, If you delete the .txt all your Saved Passwords will be deleted!
Sleep 500
MsgBox, 262196, WARNING!, Do you really want to delete the .txt?
IfMsgBox Yes
FileDelete, %Temp%\ttcrashes.txt
return
CREATE:
MsgBox, 262208, WARNING!, If you create a new .txt your old .txt file may get deleted!
Sleep 500
MsgBox, 262196, WARNING!, Do you really want to create a new .txt?
IfMsgBox Yes
FileAppend,ENCODED:, %Temp%\ttcrashes.txt
return
OPEN:
Run, %Temp%\ttcrashes.txt
return
;-------------------Key--------------------
key:
k1 := 0x5025124 ;in each of these 5 keys edit the last 10 0s to random numbers so that they are each different and look something like this: 0x1928374659
k2 := 0x0681035170
k3 := 0x9704313523
k4 := 0x0427880892
k5 := 0x8754345242
return
;----------------Exit HK--------------------
Exit:
ExitApp
return
;-----------------------------------------------
;#############################################################################################################
ENCRYPT:
encrypt = 1
decrypt = 0
GoSub, EncryptDecrypt
Return
DECRYPT:
decrypt = 1
encrypt = 0
GoSub, EncryptDecrypt
Return
;#############################################################################################################
EncryptDecrypt:
Gui, 1: Submit, NoHide
i = 9
p = 0
L =
Loop % StrLen(EncDec)
{
i++
If i > 8
{
u := p
v := k5
p++
TEA(u,v, k1,k2,k3,k4)
Stream9(u,v)
i = 0
}
StringMid c, EncDec, A_Index, 1
a := Asc(c)
If a between 32 and 126
{
If encrypt = 1
{
a += s%i%
IfGreater a, 126, SetEnv, a, % a-95
c := Chr(a)
}
If decrypt = 1
{
a -= s%i%
IfLess a, 32, SetEnv, a, % a+95
c := Chr(a)
}
}
L = %L%%c%
}
GuiControl,, EncDec, %L%
Return
;#############################################################################################################
TEA(ByRef y,ByRef z,k0,k1,k2,k3) ; (y,z) = 64-bit I/0 block
{ ; (k0,k1,k2,k3) = 128-bit key
IntFormat = %A_FormatInteger%
SetFormat Integer, D ; needed for decimal indices
s := 0
d := 0x9E3779B9
Loop 32
{
k := "k" . s & 3 ; indexing the key
y := 0xFFFFFFFF & (y + ((z << 4 ^ z >> 5) + z ^ s + %k%))
s := 0xFFFFFFFF & (s + d) ; simulate 32 bit operations
k := "k" . s >> 11 & 3
z := 0xFFFFFFFF & (z + ((y << 4 ^ y >> 5) + y ^ s + %k%))
}
SetFormat Integer, %IntFormat%
y += 0
z += 0 ; Convert to original ineger format
}
Stream9(x,y) ; Convert 2 32-bit words to 9 pad values
{ ; 0 <= s0, s1, ... s8 <= 94
Local z ; makes all s%i% global
s0 := Floor(x*0.000000022118911147) ; 95/2**32
Loop 8
{
z := (y << 25) + (x >> 7) & 0xFFFFFFFF
y := (x << 25) + (y >> 7) & 0xFFFFFFFF
x = %z%
s%A_Index% := Floor(x*0.000000022118911147)
}
}
Esc::
ExitApp
return```
Well my expected result would be that if you press the "Save" Button on the GUI you the "Encoded" string gets saved into the .txt
As stated above by Yane, the correct syntax is FileAppend [, Text, Filename, Encoding]
Using one of the below should create/modify the file as intended.
FileAppend,ENCODED: %VariableName%, %Temp%\ttcrashes.txt
or
FileAppend,%VariableName%, %Temp%\ttcrashes.txt
User contributions licensed under CC BY-SA 3.0