SHA1 hash

Discussion in 'Software' started by MohammedNgum, Jan 29, 2008.

  1. MohammedNgum

    MohammedNgum

    Joined:
    Jan 29, 2008
    Messages:
    1
    Hi,
    I wrote a program in delphi to sha1 hash user id before sending the hash value for logon as only hash values are allowed for logon. My code works but produces an incorrect hash value. I know the hash is incorrect because i cannot logon with it and a website that gives hash values produces a different value which logs me on. I have copied the code below. Any help will be appreciated. Thanks in advance.

    unit globallive;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
    IdTCPClient, DCPcrypt2, DCPsha1, DCPripemd160;

    type
    Buf = Array[0..63] of byte;
    Dig= array[0..19] of byte;
    TForm1 = class(TForm)
    IdTCPClient3: TIdTCPClient;
    Button3: TButton;
    DCP_sha11: TDCP_sha1;
    DCP_ripemd1601: TDCP_ripemd160;
    procedure Button3Click(Sender: TObject);
    procedure IdTCPClient3Connected(Sender: TObject);
    procedure SHA1Update(const Buffer: Buf; Size: longint; var Digest:Dig; username: String);

    private
    { Private declarations }
    public
    Len : longword;
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}


    procedure TForm1.Button3Click(Sender: TObject);
    begin
    IdTCPClient3.Connect('127.0.0.1',30257)
    end;

    //get user id then call hashing procedure
    procedure TForm1.IdTCPClient3Connected(Sender: TObject);
    var
    i : integer;
    Buffer : Buf;
    Digest : Dig;
    id : String;
    int : Integer;

    begin
    showMessage('connected');
    id := FormatDateTime('YYMMDDHHMM', now);
    id := id + 'demofleet';
    showMessage(id);
    ZeroMemory(@Buffer, SizeOf(Buffer));
    for i := 1 to Length(id) do
    begin
    Buffer := Byte(id);
    showMessage(Char(Buffer));
    end;
    SHA1Update(Buffer,Length(Buffer),Digest,id);
    end;
    //perform hashing and use hash value to logon
    procedure TForm1.SHA1Update(const Buffer:Buf; Size:longint; var Digest: Dig; username: String);
    var
    s : String;
    i : integer;
    str : String;
    test : Boolean;
    begin

    DCP_sha11.Init;
    showMessage('content of buffer before update');
    for i := 1 to length(username) do
    begin
    showMessage(char(Buffer));
    end;
    DCP_sha11.Update(Buffer,sizeof(Buffer));
    ZeroMemory(@Digest, SizeOf(Digest));
    showMessage('content of digest before final');
    for i := 0 to length(Digest) do
    begin
    showMessage(char(Digest));
    end;
    DCP_sha11.Final(Digest);
    showMessage('content of digest after final');
    for i := 0 to length(Digest) do
    begin
    showMessage(char(Digest));
    end;

    s:= '';
    for i:= 0 to 19 do
    s:= s + inttohex(Digest,2);
    showMessage(s);
    showMessage(inttostr(length(s)));
    //logs on fine with correct hash value
    //s:= '';
    // s := '7a0df5cff2e39ad0ebea282f03d3d5498b51dc0d';
    IdTCPClient3.IOHandler.write('LOGON,'+s+','+#13+#10);
    str := IdTCPClient3.IOHandler.ReadLn(','+#13+#10,20);
    showMessage(str);
    IdTCPClient3.Disconnect;
    end;

    end.
     
    MohammedNgum, Jan 29, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Low

    "paged" CAM table hash

    Ben Low, Oct 5, 2004, in forum: Cisco
    Replies:
    2
    Views:
    833
    Ben Low
    Oct 5, 2004
  2. Nicolas W.

    PIX: PSK, sniffer and hash

    Nicolas W., Oct 5, 2005, in forum: Cisco
    Replies:
    0
    Views:
    393
    Nicolas W.
    Oct 5, 2005
  3. AM

    CCO Hash.

    AM, Jan 4, 2006, in forum: Cisco
    Replies:
    1
    Views:
    1,118
    Tomas Knott
    Jan 8, 2006
  4. Harry

    Hash mash

    Harry, Aug 8, 2004, in forum: Computer Support
    Replies:
    1
    Views:
    585
    Morgan Pugh
    Aug 8, 2004
  5. none@set.yet
    Replies:
    1
    Views:
    2,600
    Walter Roberson
    Sep 11, 2006
Loading...

Share This Page