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

  • Home
  • SEARCH
  • 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 9041035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:08:23+00:00 2026-06-16T10:08:23+00:00

I’ve used this simple code that encrypts plain text. Then I tried to decrypt

  • 0

I’ve used this simple code that encrypts plain text. Then I tried to decrypt it using the same encrypting method but reversed in encryption section. There’s a multiplication process that I don’t know how to reverse it in the decryption code.

Here is the code:

procedure TForm1.Button1Click(Sender: TObject);
var
  s: String;
  count, ilength: Integer;
begin
  s := edit1.Text;
  ilength := Length(s);
  FOR count := 1 to ilength do
  begin
    s[count] := chr(ord(s[count]) * 4 + 1); // Encoding
  end;
  Label1.caption := s;
  // Display encoded text
  // Decoding section
  // This will probably be placed in another procedure.
  FOR count := 1 to ilength do
  begin
    s[count] := chr(ord((s[count]) / 4) - 1);
    // Here I Get An Error ! Please Help Guys, Thanks
  end;
end;
  • 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-06-16T10:08:24+00:00Added an answer on June 16, 2026 at 10:08 am

    You are trying to perform integer division. In Delphi you do that with div. The / operator is for floating point division. Looking at the code, you are trying to reverse this calculation:

    ord(s[count]) * 4 + 1
    

    You reverse that like this:

    (ord(s[count]) - 1) div 4
    

    However, your algorithm will not work. Consider what happens when you encrypt 64 and 128. You multiply by 4 to get 256 and 512 respectively. Then add one to get 257 and 513. Then you store back to an 8 bit data type and lose the higher order bytes. And so both characters are encoded to the value 1.

    I’m assuming that you are using 8 bit text. But if you are using 16 bit text, your algorithm still fails in an exactly analogous fashion. Your proposed algorithm is not reversible.

    I urge you to find an off-the-shelf encryption algorithm rather than trying to write your own. Encryption is hard to get right.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.