Results 1 to 6 of 6

Thread: SHA1 algorithm

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    8

    SHA1 algorithm

    hi i need to use SHA1 in my project well i use different SHA1 method in vb6 but nothing answer me correct but this code unit in delphi answer good

    i attach sha1 unit here so please guide me how can i convert that to vb6

    thanks
    Attached Files Attached Files

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: SHA1 algorithm

    Thread moved from the 'CodeBank VB6' forum (which is for you to post working code examples, not questions) to the 'VB6 and earlier' forum

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: SHA1 algorithm

    Throw that Delphi away and ignore a few broken examples posted here in VB as well.

    You're better off not trying to write your own cryptographic code, and in this case we have an API in Windows we can use anyway.

    See CryptoAPI MD5 Hash.

    If you had read that thread you'd see that the code can be trivially modifed for SHA1 or other hash algorithms. For example, see this attachment.
    Attached Files Attached Files

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    8

    Re: SHA1 algorithm

    hi thanks for reply your example is good but i need SHA1 encryption to doing this for that i put example here:

    All SHA1 include your example doing calculation like this:

    Sha1_init "Initialize SHA1"
    Sha1_Update(DATA) "Add Data to Encrypt"
    Sha1_Final "Encrypt Data"


    but i need to doing this:

    Sha1_init
    Sha1_Update
    Sha1_Update
    Sha1_Final

    what can i do for this type of Sha1??

    B.R

  5. #5
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    482

    Re: SHA1 algorithm

    I have a COM API (ActiveX DLL) that I wrote years ago that 100% conforms to the SHA1 standard. I can tell you right now it is not a real easy task. There are advanced math functions that VB6 does not support that you will need. So I had to write several custom math functions to get this done. For instance you need to be able to convert from Hexadecimal to Binary and to Decimal, from Binary to Decimal and back. You need bit-wise AND, OR, XOR, NOT functions. I also had to build a new way to calculate Modulus since the built in VB version is not capable of handling the lengths required for SHA calculations and would constantly give overflow errors.

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: SHA1 algorithm

    SHA1 is a hash algorithm, it does not encrypt anything.

    If you want to pass a series of blocks of data you can just unroll the HashBytes() function in my example, i.e. just make NewHash, HashBlock, and HashValue() all Public and then call those yourself.
    Last edited by dilettante; Feb 2nd, 2012 at 06:55 PM.

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