Jump to content

_StringEncrypt() and unicode


Recommended Posts

_StringEncrypt() has any thing to do with the setting of "language for non-Unicode programs" in the region and language?

because it's working for me my setting "Arabic (Egypt)" and not working with my friend his setting "Chinese (simplified, PRC)"

Edited by alaa777
Link to comment
Share on other sites

It's a suspected issue that _StringEncrypt() can be thrown off by code page/language selections. Use a true binary encryption instead. My first recommendation would be the new Crypt.au3 UDF that is now included.

There is a previous discussion of the issue mentioned here: __StringEncrypt()

:idea:

Edit: Added links

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Yep, _StringEncrypt will only work "reliably" with ANSI data (that is: not at all if the encode and decode processes don't run with the same user codepage, or if the codepage uses double byte encoding, like most Asian do). So in practice, its use it limited to ASCII, which is pretty backwards nowadays.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

AscW

Returns the unicode code of a character.

AscW ( "char" )

ChrW

Returns a character corresponding to a unicode code.

ChrW ( UNICODEcode )

;AscW
;Returns the unicode code of a character.
;AscW ( "char" )

;ChrW
;Returns a character corresponding to a unicode code.
;ChrW ( UNICODEcode )





$Txt = _StringEncryptW("abcdefg", "1234")
MsgBox(0,"_StringEncryptW",$Txt)
$Txt = _StringDecryptW($Txt, "1234")
MsgBox(0,"_StringDecryptW",$Txt)

Func _StringEncryptW($Text ,$Password)
Local $X = StringLen($Password) , $Y = 0 ,$OutTxt = ""
For $i = 1 To StringLen($Text)
$Y += 1
$ChrW1 = StringRight(StringLeft($Text,$i),1)
$ChrW2 = StringRight(StringLeft($Password,$Y),1)
if $Y = $X Then $Y = 0
$Modified = BitXOR(AscW($ChrW1),AscW($ChrW2), 255)
$Rt = Hex($Modified,2)
$OutTxt &= $Rt
Next
return $OutTxt
EndFunc

Func _StringDecryptW($HexCode ,$Password)
Local $X = StringLen($Password) , $Y = 0 ,$OutTxt = ""
For $i = 2 To StringLen($HexCode) Step 2
$Y += 1
$Rt = StringRight(StringLeft($HexCode,$i),2)
$ChrW2 = StringRight(StringLeft($Password,$Y),1)
if $Y = $X Then $Y = 0
$Modified = Dec($Rt)
$CodeW = BitXOR($Modified,AscW($ChrW2),255)
$ChrW1 = ChrW($CodeW)
$OutTxt &= $ChrW1
Next
return $OutTxt
EndFunc

صرح السماء كان هنا

 

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...