SHA snippet 1.0 PHP script

SPONSORED LINKS

    Specification

  • Version: 1.0
  • File size: 0 KB
  • File name: id=369
  • Last update:
  • Platform: Windows / Linux / BSD / Solaris
  • Language: PHP
  • Price:Freeware
  • Company: Chris Monson (View more)

SHA snippet 1.0 script description:




Publisher review:
SHA snippet - Based on the SHA algorithm as given in "Applied Cryptography" Based on the SHA algorithm as given in "Applied Cryptography"

Simple text hash: sha = new SHA; hasharray = sha.hash_text( 'hash me!' ); This returns an array of 5 32-bit integers. The SHA.hash_bytes function does the same thing, but requires an array of bytes as input. Note that the input values will be truncated if they are larger than 8 bits.

There are also some hash to string conversion functions. The naming convention admittedly could be better, but it works. sha.hash_to_string( hasharray ) Converts the hash array to an uppercase hex string.Hashing very large blocks a piece at a time: sha = new SHA; sha.init(); while (blocks_to_process) { sha.update( next_byte_array ) } hasharray = sha.finalize() NOTES: This is basically a rip off of SHAPerl.pm, which I also wrote. I discovered, much to my chagrin, that PHP does not have even the crappy 32-bit int support that Perl has, so I had to employ some funny tricks in the code to get it to use all 32 bits.

One of the most obvious of these is using an 'add' method instead of just adding numbers together. Any numbers over 32 bits don't get bit-truncated. They get corralled, which is not what I wanted.

Another trick I had to employ was splitting large numeric constants into two pieces. Apparently, you can't specify 0xffffffff. It gets set to 0. Everything up to 0x7fffffff works fine. So, I used some shifting and bitwise operators to get the needed constants.

A word on optimization: it isn't optimized. My chief concern was to get it working, and it is fast enough for my needs. If, however, you intend to try to brute force some hash values with this, either it will need some serious optimizations done, or you should be using one of the freely available C implementations.
SHA snippet 1.0 is a PHP script for Snippets scripts design by Chris Monson. It runs on following operating system: Windows / Linux / BSD / Solaris.

Operating system:
Windows / Linux / BSD / Solaris

Latest script and internet news

222

222

22

Posted on: 18 Jul 2023 22:27 by A. Brown

111

111

111

Posted on: 18 Jul 2023 22:24 by A. Brown

The permanently active Push system offered by the new Google Chrome 42

The permanently active Push system offered by the new Google Chrome 42

Hacked By !Sc-sT

Posted on: 17 Mar 2015 07:57 by A. Brown

SPREAD THE WORD

User Rating


Rating: 2.2 out of 5
Based on 13 ratings. 13 user reviews.

  • Currently 2.15 out of 5
  • 1
  • 2
  • 3
  • 4
  • 5