• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1307
  • Last Modified:

DEC Cipher in DelphiXE encode returns unicode chinese when running TOneTimePassword.execute

Dear all,

I transformed the Cipher components (DEC) that I used in my Delphi7 for DelphiXE.

You can install it for DelphiXE, by installing the "DEC.dpk" I created in the first folder of the unpacked zip file.

Problem is that I get "Chinese" characters on the encoding (instead of hexadecimal encoded string) result when I execute the

MyEncodedString:=OneTimePassword.execute(someStringToEncode).

-----------------------------
Download the ZIP containing the DEC I transformed for DelphiXE at
http://www.cybernate.gr/software/Cipher.zip
-----------------------------

Any guru please help me, I try to migrate to DelphiXE from Delphi7, and I am pulling my hair because of this unicode peculiarity...

Thanks
0
Ioannis Anifantakis
Asked:
Ioannis Anifantakis
  • 10
  • 7
1 Solution
 
aikimarkCommented:
pass in an AnsiString data type.  The default string type is now UniCode.
0
 
briangochnauerCommented:
After downloading and reviewing;
The component (written for Delphi 7) assumes that a string = ansistring (byte = char) when calculating buffers and in the math of the cipher algorithms.
I will have to have serious work done to it to get it to work with Unicode compilers (> Delphi 2009)

Even though you got i loaded into Delphi XE; it will not work.
Passing AnsiString into the Library  call will NOT work either, since the call is defined as String.
0
 
Ioannis AnifantakisSoftware EngineerAuthor Commented:
Yes, there needs lots and lots of work to be done so it can work.

Its pissing me off!
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
briangochnauerCommented:
Depending on what you need from the library you may be able to use just the .pas file you need and convert it by doing a search and replace on String and PChar and replacing them with AnsiString and PAnsiChar respectively.  Looking at the complexity of the code this will probably cascade through USES clause to nearly all the units. yuk..  I guess the original developer doesn't want to do it....
0
 
briangochnauerCommented:
Looks like all the cipers use 'var data' for input and output; that's good!
Are you converting the source?
0
 
Ioannis AnifantakisSoftware EngineerAuthor Commented:
Wherever you see compiler_6_up directive it hangs, so I comment out the compiler_6_up as you can see.

Now It ried to additionally replace String for AnsiString and PChar for PAnsiChar but failed.  In some cases it REQUIRES to have PWideChar if I change the default PChar to PAnsiChar.

I don't know... I am confused
0
 
briangochnauerCommented:
I converted it; but really don't have any way to give it a good test since I didn't see any demo apps.
(see attached file)
Cipher.exe
0
 
Ioannis AnifantakisSoftware EngineerAuthor Commented:
Allow me 30 mins to get to delphi 2009 pc and check it out.......

Actually testing it out, you have to call the execute method of the onetimepassword component and have a non-chinese hex string produced for you....

However, let me check it out... if you did it... I owe you big!
0
 
briangochnauerCommented:
found an issue; i'll look at it after lunch.
0
 
briangochnauerCommented:
I guess I don't know if it is an issue or not; did you try it?
0
 
briangochnauerCommented:
I found it, it was a dictionary error.
see attached.
Cipher.exe
0
 
briangochnauerCommented:
here is a cleaned (crap files removed) one that looks like more what you would see in a 'distributed' package. You can do with it what you want (post in one of your blog articles)
I loaded it in my Delphi 2007 environment and it worked fine too.
Cipher.exe
0
 
Ioannis AnifantakisSoftware EngineerAuthor Commented:
Hmmm.... its not chinese anymore, but I don't get the same encoding result...

I attach a sample project that is compiled and has its EXE file from Delphi7.  Save this exe file, as when you run it, you get to econde for a sample OneTimePassword setup that provides the correct encoding in Delphi7.

You can see for the same project how the modified component result differs.

You can download the sample project with the exe from the Delphi7 compile at
http://www.cybernate.gr/software/OTPProject.zip
0
 
Ioannis AnifantakisSoftware EngineerAuthor Commented:
You should produce an executable file from this project that when encodes matches the encoded password with the included EXE file that was compiled in Delphi7.

I don't know why, but when I compile the same sample file in DelphiXE I get different encoded password
0
 
briangochnauerCommented:
Hey that sample project cut a couple hours off of that fix. Thanks.
I had a good idea where it was; but when I loaded the original code in D2007 debugger and the new code in Delphi XE debugger then ran them side by side watching the results it jumped right out where the problem was.
Attached is the update.
Cipher.exe
0
 
Ioannis AnifantakisSoftware EngineerAuthor Commented:
I am amazed!

Right to it!  A "Thank you" and few "points" cannot express my gratitude.

I need to pm you about somehting
0
 
Ioannis AnifantakisSoftware EngineerAuthor Commented:
Thank you so much!
0
 
briangochnauerCommented:
Your welcome.
If you run across a Delphi PXE server component w/source in the next year or so let me know.
That would save me a lot of headache.
0

Featured Post

Put Machine Learning to Work--Protect Your Clients

Machine learning means Smarter Cybersecurity™ Solutions.
As technology continues to advance, managing and analyzing massive data sets just can’t be accomplished by humans alone. It requires huge amounts of memory and storage, as well as the high-speed power of the cloud.

  • 10
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now