old way for me when dealing with passwords and saving to ini file or even an 
xml file would be to encrypt the password and save it, then decrypt it when its 
loaded. This is simple and is not the most secure way. Using a HASH based 
system would be best. Here is a link that might help too:

http://www.codeproject.com/dotnet/SimpleEncryption.asp?df=100&forumid=172899&exp=0&select=1119915

code for a simple encryption:

function Encrypt (const s: string; Key: Word) : string;
var
  i : byte;
begin
  Result := s;
  for i := 1 to length (s) do
    begin
      Result[i] := Char (byte (s[i]) xor (Key shr 8));
      Key := (byte (Result[i]) + Key) * c1 + c2
    end
end;


function Decrypt (const s: string; Key: Word) : string;
var
  i : byte;
begin 
  Result := s; 
  for i := 1 to length (s) do 
    begin 
      Result[i] := Char (byte (s[i]) xor (Key shr 8)); 
      Key := (byte (s[i]) + Key) * c1 + c2 
    end 
end;

//*************************************
code for a hash encryption:

const HashSize=24;

function StrToHex(const Digest:String):String;
var i:Integer;
    SS: String[hashSize*2];
begin
  SS:='';
  For i:=1 to HashSize do
    begin
      SS:=SS+IntToHex(ord(Digest[i]),2);
    end;
  Result:=SS;
end;


function HashStr(S:String):String;
var i,j:Integer;
    hash:array[1..HashSize] of Byte;
begin

{Initializing Hash array}
for i:=1 to HashSize do
     Hash[i]:=($0048 + i ) mod 256;

  Result:='';
{Building Hash Table}
  for i:=1 to HashSize do
    begin
      for j:=1 to Length(s) do
        hash[i]:=Hash[i]+ord(s[j])+i{+j} mod 256;
        Result:=Result+chr(Hash[i]);
    end;

{Optional, if you save result in a StringList object kind
the result may contain "\0" symbol}
   Result:=StrToHex(Result);
end;


Usage:

procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=HashStr(Edit1.Text);
end;



d3lph1mania <[EMAIL PROTECTED]> wrote:     Dear all, how can I secure a web 
service? Because web service uses xml
 which can be tapped by someone. Is there any encryption capability in
 delphi for this reason?
 
 Sorry for this very basic question, I hope someone can enlighten me.
 
 regards
 
 Jo
 
                
---------------------------------
 Yahoo! Mail
 Use Photomail to share photos without annoying attachments.

[Non-text portions of this message have been removed]



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to