RSA Unicode Error!!

The operation results of the official example are as follows

signature:
KiCKfOe0805Ags4mZ4DWS9rSDPGt6BNtySZDdOhecbimU38GNPyBAFhNof9F/7RXaheLpi9rGZmpZgZ1/Pm4yfNTsDaArnxZcSfl5P2TvJWyrdDtwp7gnQPlB/i4tB+dLLRBvGIlGdDL4KIejWLhdZ++teHTyuLYtTcG/0iLwLVIwdypIe4J38rDK5hTh/TsPPHGgHHb94xziNvMp9wQkN+0ZVsHqWd+YbEyiDlU42wo+S0uK/OdyH6SwFOIcZbNHRvVK/wy6Yt4xh7AGEJ0j6FvVe/L8L2PNWQ9wwhjZUiylGkVxwR2CpgaFkR657YrO7CMhaZpMvFjCBUugBwrbQ==

The correct result should be:
U8g8gV5iwPcInT75+Rx4odEvGHx7zlEWW+NUrIX/Zato6cZJ0CiktW9pzQ3I0MTxiLz7ZFzeZttD3dhPaqGwK3M9G0pkY00oyYjlsA+X5V6iI0km+GpoeL8NpEvzCTRRjpnHmIPpT9B/u5FcPZxURlqIQBIfRgHaX4205xTYeVFoAu5Ob45I1KWpBOlxTprq1AjrqjJnhb0WUDQkPtGvzvfbqiZt1UUyMOqjaPSsfJ5ft5ZIUTV/gFqNxBqoUVKIlHot0ofRJqFzE8c92Nt6gdocZSXmFfCU3/ZZ5bv79KEqlcS4p3LnvGZ6+LmKg0/4YH6nhrkHzZMBUiZRnGKRJw==

If it is in English, the result is correct; if it is in Chinese, Thai, Japanese, etc., the result is wrong
I use Chinese characters “中”
It is also an official example. Click the [ sign ] button directly

-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCeZUPxiJXz8JK6
BLjLeZpJNDcfl3W5A/YXmqmbyVFDRjkT9P1NPRbnOt6i8HfzQFkLpHjSRN6Iz0VT
kONvtdIndjztDfp6i2123CjJ4Jrdq02aXLWgMyBbv4otkGSkItJrWY5+wBsXNTlD
W+duRklQnVG6BukeVuLBCYoK52yjRgaeeusEnMGsV9YWt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r4s18psj7Vn81peXWvFJO+7bM/FZFFChO2nQ4xZUz6+R+xf
+idj/bk0IUBMzjMUNqrBmeS9yveVw8QMi+ImV7CJoTEwQFonaWo9KN+4SesBbmPm
gbCcZ0JY9CQqa89TaPEPahGkfvvho1iJGYQi5PJdAoGBAKk4K8B+HOZesbKiGtgF
OGYwCAbDNqc8Xm1EVdP+Fq2XoPwRREJDGHp61bAvO4kUa6e5c3d9HMO5gOGmW4sd
gW9aYNo0XnX+RvG9aXQzqEalFinDua8a+7zscJhoztV4d58pEBUk2VFnWN0vdQMn
tXW/CWTOMu4i0z7dYWTgdR2G
-----END PRIVATE KEY-----

Looking forward to your reply, thank you

Hi,
This seems to be a conversion issue that I will investigate.
Regards,
bernard

Hi,
The project is in urgent need of use. Please help modify it as soon as possible. Thank you.

Hello, this bug, before the version upgrade, can you teach me how to manually modify the code and run normally first? thank you!

Hello, I am currently working on it. There is an error in the unicode to byte conversion and I am trying to understand why.

Here is a quick fix. Open up RSAObj.pas. In function TRSAEncSign.Sign(m: string): string:

Comment the following lines:
// mPB := conv.StringToBuffer
// (conv.FormatToString(conv.KeyRSAOpenSSLToKeyTRSAEncSign(hexam)),
// FUni, msgLen);

and add:

hexam := conv.FormatToString(conv.KeyRSAOpenSSLToKeyTRSAEncSign(hexam));

mPB := GetMemory(Length(hexam) + 1);
for I := 0 to Length(hexam) - 1 do
mpb[I] := AnsiChar(hexam[I + 1]);
mpb[I] := #0;
msgLen := Length(mPB);

Check the result on-line with CyberChef

Tested with 中, 中中, 中中中, 中中中中 and 你好

I need to fix other functions too.

OK, thanks

Hello, now use it like this. I look forward to your version upgrade. Thank you!

The signature is correct, I get the same one. I don't get any memory leak, so it means there is another issue.
I will have another look.

Hello, I'm sorry. I changed the memory leak. I misunderstood it. Thank you!

Hello, the next version upgrade will replace "libeay32.dll and ssleay32. DLL" with "libcrypto-1"_ 1-x64.dll and libssl-1_ "1-x64"? thank you!