title: How to hash using DCPcrypt?
body: <p>I have scowered the net trying to find an example of a function, how to hash text with Sha1 and DCPcrypt.</p>
  
  <p>I have the below example. Seems to pop up the whole time.
  But it returns chinese characters every time. Please assist in corecting the function.</p>
  
  <pre><code>function TForm1.EncryptThis(aString : string) : string;
  var
     Cipher: TDCP_cast256;
     KeyStr: string;
  begin
     KeyStr:= '';
     Cipher:= TDCP_cast256.Create(Self);
     Cipher.InitStr(KeyStr,TDCP_sha1);
     result := Cipher.EncryptString(aString);
     Cipher.Burn;
     Cipher.Free;
  end;
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  Using the links and info belowe, I built these functions. But as I said, This does not make alot of sense to me. So please excuse the ignorance.</p>
  
  <p>THe code however does not work. Its output is: <code>3F3F3F3F3F3F3F3F3F3F00000000000000000000</code> whereas it should be <code>40bd001563085fc35165329ea1ff5c5ecbdbbeef</code> since i told the program to has <code>123</code>.</p>
  
  <p>Please help.</p>
  
  <pre><code>function CalcDigest(text: string): string;
  var
    x: TDCP_hash;
  begin
    x := TDCP_sha1.Create(nil);
    try
      x.Init;
      x.UpdateStr(text);
      SetLength(Result, x.GetHashSize div 8);
      x.Final(Result[1]);
    finally
      x.Free;
    end;
  end;
  
  function String2Hex(const Buffer: Ansistring): string;
  begin
    SetLength(result, 2*Length(Buffer));
    BinToHex(@Buffer[1], PWideChar(@result[1]), Length(Buffer));
  end;
  
  procedure TForm1.Button1Click(Sender: TObject);
  var
    I: Integer;
  begin
    memo2.Lines.Add(String2Hex(CalcDigest(memo1.Lines.Strings[0])));
  end;
  </code></pre>