Back to index

php5  5.3.10
Classes | Functions
php_hash_adler32.h File Reference
#include "ext/standard/basic_functions.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PHP_ADLER32_CTX

Functions

PHP_HASH_API void PHP_ADLER32Init (PHP_ADLER32_CTX *context)
PHP_HASH_API void PHP_ADLER32Update (PHP_ADLER32_CTX *context, const unsigned char *input, size_t len)
PHP_HASH_API void PHP_ADLER32Final (unsigned char digest[4], PHP_ADLER32_CTX *context)
PHP_HASH_API int PHP_ADLER32Copy (const php_hash_ops *ops, PHP_ADLER32_CTX *orig_context, PHP_ADLER32_CTX *copy_context)

Class Documentation

struct PHP_ADLER32_CTX

Definition at line 26 of file php_hash_adler32.h.

Class Members
php_hash_uint32 state

Function Documentation

PHP_HASH_API int PHP_ADLER32Copy ( const php_hash_ops ops,
PHP_ADLER32_CTX orig_context,
PHP_ADLER32_CTX copy_context 
)

Definition at line 52 of file hash_adler32.c.

{
       copy_context->state = orig_context->state;
       return SUCCESS;
}
PHP_HASH_API void PHP_ADLER32Final ( unsigned char  digest[4],
PHP_ADLER32_CTX context 
)

Definition at line 43 of file hash_adler32.c.

{
       digest[0] = (unsigned char) ((context->state >> 24) & 0xff);
       digest[1] = (unsigned char) ((context->state >> 16) & 0xff);
       digest[2] = (unsigned char) ((context->state >> 8) & 0xff);
       digest[3] = (unsigned char) (context->state & 0xff);
       context->state = 0;
}

Definition at line 25 of file hash_adler32.c.

{
       context->state = 1;
}
PHP_HASH_API void PHP_ADLER32Update ( PHP_ADLER32_CTX context,
const unsigned char *  input,
size_t  len 
)

Definition at line 30 of file hash_adler32.c.

{
       php_hash_uint32 i, s[2];
       
       s[0] = context->state & 0xffff;
       s[1] = (context->state >> 16) & 0xffff;
       for (i = 0; i < len; ++i) {
              s[0] = (s[0] + input[i]) % 65521;
              s[1] = (s[1] + s[0]) % 65521;
       }
       context->state = s[0] + (s[1] << 16);
}