Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3876094
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:20:32+00:00 2026-05-19T22:20:32+00:00

I’m in the process of implementing XML digital signatures. I’m starting with little steps,

  • 0

I’m in the process of implementing XML digital signatures. I’m starting with little steps, so right now I want to solve the problem of SHA-1 hashing.

There are lots of questions about this in SO:

  1. Digitially Sign Key with Lockbox
  2. Encryption library for Delphi
  3. Convert this php digital signing to Delphi
  4. Delphi: is there a version of LockBox for Delphi-XE
  5. Delphi 2010 Cryptography libraries

…and probably more. However, I’m using Delphi XE. So far, I’ve tried LockBox 2 (both the Songbeamer and Sourceforge versions), Lock Box 3, DCPCrypto2 and some others (Hashes is an easy to use unit which uses Windows crypto functions)

I prepared a small test rig that gives me the following:

LockBox2

FAILED: 1 ('abc') 
       Got: '9f04f41a848514162050e3d68c1a7abb441dc2b5'
  Expected: 'a9993e364706816aba3e25717850c26c9cd0d89d'
FAILED: 2 ('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq') 
       Got: '51d7d8769ac72c409c5b0e3f69c60adc9a039014'
  Expected: '84983e441c3bd26ebaae4aa1f95129e5e54670f1'

LockBox3

FAILED: 1 ('abc') 
       Got: '9f04f41a848514162050e3d68c1a7abb441dc2b5'
  Expected: 'a9993e364706816aba3e25717850c26c9cd0d89d'
FAILED: 2 ('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq') 
       Got: '51d7d8769ac72c409c5b0e3f69c60adc9a039014'
  Expected: '84983e441c3bd26ebaae4aa1f95129e5e54670f1'

DCPCrypto2

FAILED: 1 ('abc') 
       Got: '9f04f41a848514162050e3d68c1a7abb441dc2b5'
  Expected: 'a9993e364706816aba3e25717850c26c9cd0d89d'
FAILED: 2 ('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq') 
       Got: '51d7d8769ac72c409c5b0e3f69c60adc9a039014'
  Expected: '84983e441c3bd26ebaae4aa1f95129e5e54670f1'

Hashes

Test 1 passes
Test 2 passes

Have you succeeded in compile the mentioned libraries under Delphi XE and make them give the appropriate values? I’m particularly interested in DCPCrypt2 SelfTest procedure.

Edit: I’ve added this answer with the fixed source code. Thank you all for your help, it is most appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:20:32+00:00Added an answer on May 19, 2026 at 10:20 pm

    Leonardo, i think which your problem is the UNICODE when you uses a function to hash a string you are passing a array (buffer) of bytes. so when you pass the abc string in Delphi XE, your are hashing a buffer like this 61 00 62 00 63 00 (Hex representation)

    check this sample application which uses the Windows crypto functions from the Jwscl library (JEDI Windows Security Code Lib)

    program Jwscl_TestHash;
    
    {$APPTYPE CONSOLE}
    
    uses
      JwsclTypes,
      JwsclCryptProvider,
      Classes,
      SysUtils;
    
    function GetHashString(Algorithm: TJwHashAlgorithm; Buffer : Pointer;Size:Integer) : AnsiString;
    var
      Hash: TJwHash;
      HashSize: Cardinal;
      HashData: Pointer;
      i       : Integer;
    begin
      Hash := TJwHash.Create(Algorithm);
      try
        Hash.HashData(Buffer,Size);
        HashData := Hash.RetrieveHash(HashSize);
        try
            SetLength(Result,HashSize*2);
            BinToHex(PAnsiChar(HashData),PAnsiChar(Result),HashSize);
        finally
          TJwHash.FreeBuffer(HashData);
        end;
      finally
        Hash.Free;
      end;
    end;
    
    
    function GetHashSHA(FBuffer : AnsiString): AnsiString;
    begin
       Result:=GetHashString(haSHA,@FBuffer[1],Length(FBuffer));
    end;
    
    function GetHashSHA_Unicode(FBuffer : String): String;
    begin
       Result:=GetHashString(haSHA,@FBuffer[1],Length(FBuffer)*SizeOf(Char));
    end;
    
    begin
     try
         Writeln(GetHashSHA('abc'));
         Writeln(GetHashSHA('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'));
         Writeln(GetHashSHA_Unicode('abc'));
         Writeln(GetHashSHA_Unicode('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'));
         Readln;
     except
        on E:Exception do
        begin
            Writeln(E.Classname, ':', E.Message);
            Readln;
        end;
     end;
    
    end.
    

    this return

    abc AnsiString

    A9993E364706816ABA3E25717850C26C9CD0D89D

    abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq AnsiString

    84983E441C3BD26EBAAE4AA1F95129E5E54670F1 for

    abc unicode

    9F04F41A848514162050E3D68C1A7ABB441DC2B5

    abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq Unicode

    51D7D8769AC72C409C5B0E3F69C60ADC9A039014

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to show the soap response to UIWebview.. my soap response is, <p><img

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.