Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>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 <code>sTestToConvert</code> even after calling <code>Encrypt</code>?</p> <p>More likely, I expect you mean that when you call <code>Decrypt</code>, you only get part of the original string back.</p> <p>That's because <code>Encrypt</code> may store <em>any</em> byte value in the result, including non-printing characters, even <code>#0</code>, the null character. When you store such a string in a <code>TMemo</code> or <code>TEdit</code>, the underlying Windows control treats the <code>#0</code> character as the end of the string. It doesn't store the rest of the encrypted value. Thus, when you call <code>Decrypt</code> on what's stored in the edit control, you are only decrypting a portion of what you originally had.</p> <p>If you want to have a text version of the encrypted data, use the <code>Encode</code> and <code>Decode</code> functions; the <a href="http://help.madshi.net/madCryptUnit.htm" rel="noreferrer">documentation online</a> mentions this. Those use base-64 encoding.</p> <pre><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 := 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; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload