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
Printable View
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
Thread moved from the 'CodeBank VB6' forum (which is for you to post working code examples, not questions) to the 'VB6 and earlier' forum
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.
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
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.
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.