Sign in to follow this  
Followers 0
Spider001

IniWrite

9 posts in this topic

#1 ·  Posted (edited)

Hey

What is the max length from a string that i can use at IniWrite and iniRead?

IniWrite ( "filename", "section", "key", "max length ?" )

Because that maybe the problem from here? I encrypt and write this to a ini file

Thank you

Will do more test to morrow

Edited by Spider001

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If you are referring to this string

 

'OLse2YGrw0XUj6Jct9Kv4Ida7MPom5Ru1 '

 

Then that is well inside the acceptable length.

In fact, that is quite short ... unless you are using an old version of Windows (i.e. 3.1 or 95).

However, if you have both a leading and trailing quote, you will get errors, as they get stripped off ... a Windows' thing.

One or the other is acceptable.

There are other characters too, that screw up ini entries (i.e. square brackets, carriage return, etc)

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

That text is acceptebel but i write the encrypte string to the ini and read it to uncrypt

Share this post


Link to post
Share on other sites

Spider001,

From Help file...

 

MAX_STRINGLEN 2,147,483,647 Maximum string length.

 

Post runnable reproducer for better help...

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Make sure what you're writing is in hex for you ini and not raw binary, any null char and it ends the string.  Then convert the hex back to binary before decrypting.

Are you running a 64 or 32 bit exe?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

on a 32bit xp no problem

on 64 bit 8.1 problem

and that's the problem

password to encrypt 'OLse2YGrw0XUj6Jct9Kv4Ida7MPom5Ru1 '

key that's be saved at the ini

0x01000000D08C9DDF0115D1118C7A00C04FC297EB010000001886711E8F5CDD49A6C4DE2DCDB482500000000028000000300031002F00320037002F0032003000310035002000320031003A00310033003A00300038000000106600000001000020000000C0CF70165F353813BA14B9BF88FB4714EDB170E39202C848B5414473B237AAAB000000000E800000000200002000000016E5F2CACF72BABE1B385B2A49185C3BAC1B62099B2D542B4C40C63EC035CED6200000005D5E62316A90AFDF772FAC4F5010BEF9F65C884C264C20F10D41BF5D77C206DD40000000A7167816D2B655D8EA953D8A225FD97EC4DCB65DAB11D538A674DF97206091378E8B9FF7252B9136B2809101CCF770EBAFF67428623A5E291ABE70D4E6069A1C

password after decrypt OLse2YGrw0XUj6Jct9Kv

#include <CryptProtect.au3>
#include <Date.au3>


Func _unprotect($data)
   If $data <> '' Then
      Local $sDesc='',$iError2,$iExtended2
      $data = _CryptUnprotectData($data, $sDesc)
      $iError2 = @error
      $iExtended2 = @extended
      If $iError2 > 0 Or $iExtended2 > 0 Then
         MsgBox(0,'error',"Error protecting: " & $iError2 & @LF & "Windows error protecting: " & $iExtended2)
         Exit
      EndIf
      Return $data
   Else
      Return ''
   EndIf
EndFunc

Func _protect($data)
   Local $iError1,$iExtended1
   Local $tCur = _Date_Time_GetLocalTime()
   $tCur = _Date_Time_SystemTimeToDateTimeStr($tCur)
   $data = _CryptProtectData($data, $tCur)
   $iError1 = @error
   $iExtended1 = @extended
   If $iError1 > 0 Or $iExtended1 > 0 Then
      MsgBox(0,'error',"Error protecting: " & $iError1 & @LF & "Windows error protecting: " & $iExtended1)
      Exit
   EndIf
   Return $data
EndFunc

ConsoleWrite(@AutoItVersion & @CRLF)
ConsoleWrite('OLse2YGrw0XUj6Jct9Kv4Ida7MPom5Ru1 ' & @CRLF)
$data = _protect('OLse2YGrw0XUj6Jct9Kv4Ida7MPom5Ru1 ')
IniWrite(@TempDir & "\Example.ini", "General", "Title", $data)
ConsoleWrite($data & @CRLF)
$data = _unprotect(IniRead(@TempDir & "\Example.ini", "General", "Title", ""))
ConsoleWrite($data & @CRLF)
Edited by Spider001

Share this post


Link to post
Share on other sites

I wasn't asking what operating system. I was asking what you were compiling it at.  I'm curious if the tags for the udf you're using were properly set for both.

So...

1.  On your 64bit machine, put this at the top of it (your script):

#AutoIt3Wrapper_UseX64=N

2.  As I said, you may need to convert back to binary... eg:

_unprotect(Binary(IniRead(@TempDir & "\Example.ini", "General", "Title", "")))

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

i compile it to 64 bit exe for 64 bit os

and 32bit exe for xp

develop on 32bit

i have always tryed on 64bit with 64 bit exe

SmOke_N will try your solutions

thanks for the help

Edited by Spider001

Share this post


Link to post
Share on other sites

Binary() did it thank you

Share this post


Link to post
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
Sign in to follow this  
Followers 0