Results 1 to 2 of 2

Thread: [DELPHI] - Encode Password

  1. #1

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    [DELPHI] - Encode Password

    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    var
      s: String[255];
      c: array[0..255] of Byte absolute s;
      i: Integer;
    begin
      //Encode
    
      s := 'Sample';
      for i := 1 to Ord(s[0]) do c[i] := 23 xor c[i];
      Label1.Caption := s;
    
      //Decode
    
      s := Label1.Caption;
      for i := 1 to Length(s) do s[i] := Char(23 xor Ord(c[i]));
      Label2.Caption := s;
    end;

  2. #2

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Re: [DELPHI] - Encode Password

    This cleaned up version illustrates the use of 2 TEdit boxes, the first TEdit box (txtEnterPassword) is the original pass string, and the second TEdit (txtEncryptedPassword) is the encoded pass string.

    Code:
    procedure TfrmPasswordEncrypter.cmdEncryptClick(Sender: TObject);
    var
      s: String[255];
      c: array[0..255] of Byte absolute s;
      i: Integer;
    begin
      //Encode
    
      s:= txtEnterPassword.Text;
      for i:= 1 to Ord(s[0]) do c[i]:= 23 xor c[i];
      txtEncryptedPassword.Text:= s;
    
      //Decode
    
      s:= txtEncryptedPassword.Text;
      for i:= 1 to Length(s) do s[i]:= Char(23 xor Ord(c[i]));
      txtEnterPassword.Text:= s;
    end;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width