Jump to content

Encrypt file decrypt to string [SOLVED]


nend
 Share

Recommended Posts

Is it posible to encrypt a txt file and open it in a other program to only read it to string without saving it first.

Everyting I tryd won't give me the data in the console.

#include <Crypt.au3>


$import_file = FileOpenDialog("Encrypt file", "", "TEXT (*.txt)")
If $import_file <> "" Then
    $dir = StringTrimRight($import_file, StringLen($import_file) - StringInStr($import_file, "\", 0, -1))
    $name = StringReplace(StringTrimLeft($import_file, StringInStr($import_file, "\", 0, -1)), ".txt", "")
    _Crypt_EncryptFile($import_file, $dir & "/" & $name & ".trs", "BLA", $CALG_AES_128)
EndIf


$file_handle = FileOpen($dir & "/" & $name & ".trs", 0)
$file_to_string = FileRead($file_handle)
$return_string = _Crypt_DecryptData($file_to_string, "Bla", $CALG_AES_128)
FileClose($file_handle)
ConsoleWrite(BinaryToString($return_string) & @CRLF)

Thanks!

Edited by nend
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...