login about faq

I am using VB.net 2010 and I’m trying to get SHA1 output that matches the output from the PHP SHA1 function with the raw_output parameter set to true.

Would you know if this is possible with Chilkat Crypt and if so would you have any example code. I am using the trial version right now and am unable to get the same results as the PHP function.

asked Dec 07 '12 at 11:25

chilkat's gravatar image

chilkat ♦♦

SHA-1 produces 20 bytes of output. I knew nothing about PHP SHA1 / raw_output, so I did a Google search on "PHP SHA1 raw_output" -- easy enough to find out. The raw_output is the exact 20 bytes of output. (makes sense) However, don't try to display these bytes as characters -- because they're not characters. (How would you display a 0 byte, or control-characters??)

With Chilkat, you can get the output as a byte array, or the encoded representation of the raw bytes using hex, base64, or many other encodings. Assuming you are hashing the exact same input data, the result should be the same. You can verify you're getting what you expect by using a test vector. For example, see this: http://en.wikipedia.org/wiki/SHA-1

SHA1("The quick brown fox jumps over the lazy dog")
= 2fd4e1c6 7a2d28fc ed849ee1 bb76e739 1b93eb12
This is the result, displaying the bytes in hex format, that both Chilkat and PHP should produce for the above string.


answered Dec 07 '12 at 11:32

chilkat's gravatar image

chilkat ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Dec 07 '12 at 11:25

Seen: 1,971 times

Last updated: Dec 07 '12 at 11:32

powered by OSQA