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 215281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:27:20+00:00 2026-05-11T18:27:20+00:00

I am trying to encrypt a string but often only part of the string

  • 0

I am trying to encrypt a string but often only part of the string is being encrypted. I don’t see anyone else having this problem so I am probably doing something wrong. I have the same problem in Delphi 2007 and 2009. I am using Win XP SP3. Here is the code:

procedure TForm1.Button1Click(Sender: TObject);
var
  sTestToConvert: ansistring;
  sPassword: ansistring;
begin
  sTestToConvert := trim(Memo1.Text);
  sPassword := trim(Edit1.Text);
  madCrypt.Encrypt(sTestToConvert, sPassword);
  Memo2.Text := sTestToConvert;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  sTextToConvert: ansistring;
  sPassword: ansistring;
begin
  sPassword := trim(Edit1.Text);
  sTextToConvert := trim(memo2.Text);
  madCrypt.Decrypt(sTextToConvert, sPassword);
  Memo1.Text := sTextToConvert;
end;

I also have the same problem when trying to use OldEncrypt and OldDecrypt. Any ideas on what is causing the problem? Thanks.

  • 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-11T18:27:21+00:00Added an answer on May 11, 2026 at 6:27 pm

    I’m not sure what you mean when you say “only part of the string is being encrypted.” Do you mean that you can still see some of the plaintext in sTestToConvert even after calling Encrypt?

    More likely, I expect you mean that when you call Decrypt, you only get part of the original string back.

    That’s because Encrypt may store any byte value in the result, including non-printing characters, even #0, the null character. When you store such a string in a TMemo or TEdit, the underlying Windows control treats the #0 character as the end of the string. It doesn’t store the rest of the encrypted value. Thus, when you call Decrypt on what’s stored in the edit control, you are only decrypting a portion of what you originally had.

    If you want to have a text version of the encrypted data, use the Encode and Decode functions; the documentation online mentions this. Those use base-64 encoding.

    procedure TForm1.Button1Click(Sender: TObject);
    var
      sTestToConvert: AnsiString;
      sPassword: AnsiString;
    begin
      sTestToConvert := Trim(Memo1.Text);
      sPassword := Trim(Edit1.Text);
      madCrypt.Encrypt(sTestToConvert, sPassword);
      Memo2.Text := madCryt.Encode(sTestToConvert);
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    var
      sTextToConvert: AnsiString;
      sPassword: AnsiString;
    begin
      sPassword := Trim(Edit1.Text);
      sTextToConvert := madCrypt.Decode(Memo2.Text);
      madCrypt.Decrypt(sTextToConvert, sPassword);
      Memo1.Text := sTextToConvert;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am trying to Encrypt a string to invoke a web service from
I'm trying to encrypt some content with an RSA private key. I'm following this
Talking about javax.crypto.Cipher I was trying to encrypt data using Cipher.getInstance(RSA/None/NoPadding, BC) but I
We are having difficulty decrypting a string in ColdFusion that was previously encrypted with
I'm trying to figure out how to encrypt / decrypt a string in VB.Net.
I am trying to implement password based encryption algorithm, but I get this exception:
i am trying to encrypt and decrypt a string using RSA algorithm. Here the
I am trying to encrypt a string with AES 128 encryption, using CBC mode,
I'm trying to get the current machineKey that is being used to encrypt/decrypt my
I'm trying to encrypt a string on Android with AES. The symmetric key is

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.