Solved

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

Posted on 2010-11-26
19
1,259 Views
Last Modified: 2012-05-10
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
Comment
Question by:ioannisa
  • 10
  • 7
19 Comments
 
LVL 45

Expert Comment

by:aikimark
ID: 34221939
pass in an AnsiString data type.  The default string type is now UniCode.
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34238651
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
 
LVL 6

Author Comment

by:ioannisa
ID: 34238667
Yes, there needs lots and lots of work to be done so it can work.

Its pissing me off!
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34238707
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
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34238784
Looks like all the cipers use 'var data' for input and output; that's good!
Are you converting the source?
0
 
LVL 6

Author Comment

by:ioannisa
ID: 34239723
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
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34240278
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
 
LVL 6

Author Comment

by:ioannisa
ID: 34240346
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
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34240926
found an issue; i'll look at it after lunch.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Expert Comment

by:briangochnauer
ID: 34242719
I guess I don't know if it is an issue or not; did you try it?
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34243264
I found it, it was a dictionary error.
see attached.
Cipher.exe
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34243705
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
 
LVL 6

Author Comment

by:ioannisa
ID: 34247755
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
 
LVL 6

Author Comment

by:ioannisa
ID: 34247772
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
 
LVL 5

Accepted Solution

by:
briangochnauer earned 500 total points
ID: 34248324
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
 
LVL 6

Author Comment

by:ioannisa
ID: 34248401
I am amazed!

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

I need to pm you about somehting
0
 
LVL 6

Author Closing Comment

by:ioannisa
ID: 34248417
Thank you so much!
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34248535
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

In this era, as you know, cybercrime and other sorts of frauds using the internet has increased day by day. We should protect our information assets and confidential information from getting exploiting by the attacker or intruders. Most of the fraud…
As a financial services provider, your business is impacted by two of the strictest federal regulations on record: the Sarbanes-Oxley Act and the Gramm-Leach-Bliley Act. Correctly implementing faxing into your organization to provide secure, real-ti…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now