Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6932575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:43:24+00:00 2026-05-27T11:43:24+00:00

I recently took some code from Delphi 2007 and upgraded it to Delphi 2009.

  • 0

I recently took some code from Delphi 2007 and upgraded it to Delphi 2009. That may or may not be relevant.

But when I run the code on my computer the decryption of the password is not decrypting correctly. Here is the code.

Seed := GenerateIntFromString('usercode');

// Check if a password already exists
if TableUser.FieldByName('PASSWORD').AsString <> '' then
begin
    EncodedPassword := TableUser.FieldByName('PASSWORD').AsString;
    DecodedPassword := EncryptDecrypt(EncodedPassword, Seed);
//etc.. And the function

function TLogonForm.EncryptDecrypt(Input: string; Seed: integer) : string;
var
i : integer;
Output : string;
begin
    RANDSEED := Seed;
    Output := '';
    for i := 1 to Length(Input) do
        Output := Output + Chr(Ord(Input[i]) XOR (RANDOM(254) + 1));
    Result := Output;
end;

So if my usercode is TD
and my password is ‘JOEJOE’

the encrypted password is: ì?Âp?

the decrypted passowrd is: JìEJùE

It should decrypt as JOEJOE obviously. The kicker, if I build the code and send the exe to another user it decrypts fine. This leads me to believe its not something wrong with the code rather some anomaly with my computer. What could it be?


You can disgard this because its probably not related. I only mention it because it’s another case where something works fine on one computer but not the other.

But there is also one case where when trying to set a filter

TableUser2.Filter := FilterString;

it works fine for me, but the other user gets an error.

TableUser2: Error 3106: Unsupported operator found in a record filter expression.

Even when we filter by the same name running the same code. Maybe a database issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:43:24+00:00Added an answer on May 27, 2026 at 11:43 am

    Try doing a port from Ansi to Unicode like this:

    function TLogonForm.EncryptDecrypt(Input: AnsiString; Seed: integer) : AnsiString;
    var
    i : integer;
    Output : AnsiString;
    begin
        RANDSEED := Seed;
        Output := '';
        for i := 1 to Length(Input) do
            Output := Output + AnsiChar(Ord(Input[i]) XOR (RANDOM(254) + 1));
        Result := Output;
    end;
    

    My best wild guess is that the expected results are different because of the difference between AnsiChar and UnicodeChar. If you managed to generate some invalid codepoints that can’t be stored in your DB’s non-unicode data field, you might have some fun errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently upgraded from Delphi 4 to Delphi 2009. With Delphi 4 I had
I recently saw some Perl code that confused me. I took out all of
Recently I took a look at some code I'd committed to our version control
Recently, i took ownership of some c++ code. I am going to maintain this
Someone recently took a look of my code and commented that it was too
I recently took my Db initiating code out of the __construct of my Page
I recently took over a project that has a pretty dirty database... The table
Recently I encountered a bug in an application I took over from another developer.
This task has already been asked/answered, but I recently had a job interview that
I was recently on CodeSchool's website and took the JQueryAir course that features a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.