Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Issue with Unicode !

 Post Reply Post Reply
Author
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Topic: Issue with Unicode !
    Posted: 10 Jan 2019 at 7:53am
When The text to Encrypt contain language such as :Japanese ,Thai ,Chinese ,

Then when Decrypt the text ,the result is wrong with ???

See the demo
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jan 2019 at 7:57am
https://mega.nz/#!8Eoj2Yxa
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jan 2019 at 8:03am
Back to Top
Marion Candau View Drop Down
Member
Member
Avatar

Joined: 12 Aug 2016
Posts: 73
Post Options Post Options   Quote Marion Candau Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jan 2019 at 9:13am
Hi,
Which OS and which language configuration do you have?
In my PC it works, as you can see in this video : https://cyberens.fr/AESChineseCharacters.mp4
To convert Unicode characters, we use TEncoding.UTF8.GetBytes function.
My encrypted string result in hexa is : BDFA44EBBB4EBC7AA518882D105205492B4EC73C96C33557F97B43F74FA588CE2010993DF6DE7560C8F6B8A5F4C97D6A0B3BE1BA5DAFA9D482BBA8DB15F19B8F
Do you have the same? (to know if the issue is in encryption or decryption)
Best regards,
Marion
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jan 2019 at 1:49am
OS:win 7 sp1
OS Language :Chinese
IDE:10.2.3
3.3.1.3

My encrypted string result in hexa is
0B6E649910308CD9E6F5FB6D07D2A0D8A72A8A0997C7924279E472BDBE469F9D201735491CC57562E8F8D68C86EF0E03C11BCEF970F1A5AEA37178AD0559A931
Back to Top
Marion Candau View Drop Down
Member
Member
Avatar

Joined: 12 Aug 2016
Posts: 73
Post Options Post Options   Quote Marion Candau Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jan 2019 at 9:32am
Ok, the problem is only an Unicode problem.

Could you send me the result of
s := Convert1.CharToFormat(Convert1.StringToBuffer(edt1.Text, yesUni, msgLen), msgLen);
with Convert1 a TConvert component, msgLen an integer and s a string?

Secondly, you have put AES IVMode to userdefined so you have to set an IV. For example, put the same value as the key. Without setting an IV value, the IV value is undefined and the decryption can fail.

Marion
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jan 2019 at 10:00am
var msgLen:Integer;
s:string;
begin
s:=cnvrt1.CharToFormat(cnvrt1.StringToBuffer(edt1.Text, yesUni, msgLen), msgLen);

68656C6C6FE38193E38293E381ABE381A1E381AF20E0B8AAE0B8A7E0B8B1E0B8AAE0B894E0B8B520EC9588EB8595ED9598EC84B8EC9A946869
Back to Top
Marion Candau View Drop Down
Member
Member
Avatar

Joined: 12 Aug 2016
Posts: 73
Post Options Post Options   Quote Marion Candau Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jan 2019 at 10:04am
I have the same value, so the issue is not in StringToBuffer function.

Could you try the following code with your string s?
s := cnvrt1.StringToUnicode(cnvrt1.FormatToString(s));
And send me the new s value?

Marion
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 12 Jan 2019 at 1:32am
var msgLen:Integer;
s:string;
begin
s:=cnvrt1.CharToFormat(cnvrt1.StringToBuffer(edt1.Text, yesUni, msgLen), msgLen);
s := cnvrt1.StringToUnicode(cnvrt1.FormatToString(s));
edt2.Text:=s;
end;


helloこんにちは สวัสดี 안녕하세요hi
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 12 Jan 2019 at 1:54am
with the old code ,after set pc's zone and langguange to english,the Decrypt result is ok!


procedure TForm1.btn1Click(Sender: TObject);
var msgLen:Integer;
s:string;
begin
//s:=cnvrt1.CharToFormat(cnvrt1.StringToBuffer(edt1.Text, yesUni, msgLen), msgLen);
//s := cnvrt1.StringToUnicode(cnvrt1.FormatToString(edt1.Text));
edt2.Text:=asncryptn1.Encrypt(edt1.Text);
end;

procedure TForm1.btn2Click(Sender: TObject);
begin
 edt3.Text:=asncryptn1.Decrypt(edt2.Text)
end;
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 13 Jan 2019 at 9:34am
I think the issue is in Decrypt.

1, I use my app and get the Encrypted text under OS Chinese.
2,Then I set my pc's language to English,restart pc
3,Run app,I paste the Encrypted text to edit2
4 ,Decrypt the text

I get the right result.
Back to Top
Marion Candau View Drop Down
Member
Member
Avatar

Joined: 12 Aug 2016
Posts: 73
Post Options Post Options   Quote Marion Candau Quote  Post ReplyReply Direct Link To This Post Posted: 14 Jan 2019 at 9:20am
Hi,
Do you put an IV value for encryption and the same for decryption?
I think you are right, the issue is surely in Decrypt function. I will run more tests.
Could you try to put asncryptn1.Unicode := yesUni; before encryption and asn1crypt1.Unicode := noUni; before decryption and send me the value of edt3.Text ?
Marion
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 14 Jan 2019 at 10:10am
procedure TForm1.btn1Click(Sender: TObject);
var msgLen:Integer;
s:string;
begin
//s:=cnvrt1.CharToFormat(cnvrt1.StringToBuffer(edt1.Text, yesUni, msgLen), msgLen);
//s := cnvrt1.StringToUnicode(cnvrt1.FormatToString(edt1.Text));
asncryptn1.Unicode := yesUni;
edt2.Text:=asncryptn1.Encrypt(edt1.Text);
end;

procedure TForm1.btn2Click(Sender: TObject);
begin
asncryptn1.Unicode := noUni;
 edt3.Text:=asncryptn1.Decrypt(edt2.Text)
end;

OC3B2SA3SYCHU4EQ6CWS36YBVDBFHY2YX6H3SVH6GIJVMUHH5QNOPZUQRIBA23UA3XSFYYLK64IPX3GKKQPWXQ5DR7WLJIN5USDEFF4JSZGT4DDAZPPCPPY7JTO5U2TV


hello??????????????? ?????????????????? ???????????????hi


Back to Top
Marion Candau View Drop Down
Member
Member
Avatar

Joined: 12 Aug 2016
Posts: 73
Post Options Post Options   Quote Marion Candau Quote  Post ReplyReply Direct Link To This Post Posted: 14 Jan 2019 at 10:23am
I think we are close to fixing the issue.
Do you have registered version of TMS Cryptography Pack or trial version?
Marion
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 14 Jan 2019 at 1:38pm
I have tms all acess!

You should other compoent of Cryptography,I found some of them also have this issue!
Back to Top
Marion Candau View Drop Down
Member
Member
Avatar

Joined: 12 Aug 2016
Posts: 73
Post Options Post Options   Quote Marion Candau Quote  Post ReplyReply Direct Link To This Post Posted: 14 Jan 2019 at 1:42pm
Ok I think the issue is in the following code in AESObj.pas at the end of the Decrypt function:
for I := 0 to outputSizeBytes^ - 1 do
{$IF (defined(MSWINDOWS) or defined(MACOS)) and (not defined(IOS))}
      Result := Result + string(outputBuffer);
{$ELSE}
      Result := Result + chr(outputBuffer);
{$IFEND}

Could your try to test by replacing this code with the following one?
Result := conv.CharToFormat(outputBuffer, outputSizeBytes^);
Result := conv.FormatToString(Result);

Marion

Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 15 Jan 2019 at 12:47am
OK,NOW result is ok!
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 15 Jan 2019 at 12:59am
speck,salsa and so more ,also have this issue!
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 15 Jan 2019 at 1:02am
a
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 15 Jan 2019 at 1:03am
33
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 15 Jan 2019 at 1:03am
7
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 15 Jan 2019 at 1:04am
2
Back to Top
Marion Candau View Drop Down
Member
Member
Avatar

Joined: 12 Aug 2016
Posts: 73
Post Options Post Options   Quote Marion Candau Quote  Post ReplyReply Direct Link To This Post Posted: 15 Jan 2019 at 9:03am
Thank you very much!
I will fix the bug where it is located in all components and release a new version.
Marion
Back to Top
Fei Sun View Drop Down
New Member
New Member
Avatar

Joined: 03 Apr 2017
Posts: 20
Post Options Post Options   Quote Fei Sun Quote  Post ReplyReply Direct Link To This Post Posted: 15 Jan 2019 at 9:32am
Be quick! 
Thank you !
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down