Jump to content

[Help]_stringencrypt


FoxWizzy
 Share

Recommended Posts

I want to have a program to encript a string and write it to a file

E.x. file1 ...

Then read file1 decript the code and write it to another file

E.x. file2

the code works up to write the encripted string in file1 but in file2 all i get it 0 or "

can you please help

#include <GUIConstantsEx.au3>
#include <String.au3>


Opt("MustDeclareVars",1)

Global $lvl, $input, $input2

start()
logi()

Func start()
    Local $msg, $button

    $lvl = 1

    GUICreate("Test")

    $input = GUICtrlCreateInput("Input",0, 25)
    $input2 = GUICtrlCreateInput("Input2",0, 50)
    $button = GUICtrlCreateButton("Button",0, 75)

    GUISetState(@SW_SHOW)

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $button
                Call("logi")
        EndSelect
    WEnd
EndFunc

Func logi()
    Local $read, $read2, $file, $file2, $te

    $read = GUICtrlRead($input)
    $read2 = GUICtrlRead($input2)

    $file = FileOpen("C:\Test.txt",2)

    FileWrite($file,_StringEncrypt(1,$read,$read2,$lvl))

    FileClose($file)

    $te = FileRead($file)

    $file2 = FileOpen("C:\Test2.txt",2)

    FileWrite($file2,_StringEncrypt(0,$te,$read2,$lvl))

    FileClose($file2)


EndFunc
Link to comment
Share on other sites

You've forgot to reopen the first file, in read-mode, after you closed it. Read the FileOpen function description; you don't need to close the file handle to read from it.

#include <Constants.au3>

$hFile = FileOpen(@ScriptDir & "\Test1.txt", 2)
FileWrite($hFile, "123")
FileSetPos($hFile, 0, $FILE_BEGIN)
$sText = FileRead($hFile)

ConsoleWrite($sText & @CRLF)
FileClose($hFile)
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...