Back to index

php5  5.3.10
Classes | Functions
php_hash_crc32.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_CRC32_CTX

Functions

PHP_HASH_API void PHP_CRC32Init (PHP_CRC32_CTX *context)
PHP_HASH_API void PHP_CRC32Update (PHP_CRC32_CTX *context, const unsigned char *input, size_t len)
PHP_HASH_API void PHP_CRC32BUpdate (PHP_CRC32_CTX *context, const unsigned char *input, size_t len)
PHP_HASH_API void PHP_CRC32Final (unsigned char digest[4], PHP_CRC32_CTX *context)
PHP_HASH_API int PHP_CRC32Copy (const php_hash_ops *ops, PHP_CRC32_CTX *orig_context, PHP_CRC32_CTX *copy_context)

Class Documentation

struct PHP_CRC32_CTX

Definition at line 26 of file php_hash_crc32.h.

Class Members
php_hash_uint32 state

Function Documentation

PHP_HASH_API void PHP_CRC32BUpdate ( PHP_CRC32_CTX context,
const unsigned char *  input,
size_t  len 
)

Definition at line 40 of file hash_crc32.c.

{
       size_t i;
       
       for (i = 0; i < len; ++i) {
              context->state = (context->state >> 8) ^ crc32b_table[(context->state ^ input[i]) & 0xff];
       }
}
PHP_HASH_API int PHP_CRC32Copy ( const php_hash_ops ops,
PHP_CRC32_CTX orig_context,
PHP_CRC32_CTX copy_context 
)

Definition at line 69 of file hash_crc32.c.

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

Definition at line 49 of file hash_crc32.c.

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

Definition at line 26 of file hash_crc32.c.

{
       context->state = ~0;
}
PHP_HASH_API void PHP_CRC32Update ( PHP_CRC32_CTX context,
const unsigned char *  input,
size_t  len 
)

Definition at line 31 of file hash_crc32.c.

{
       size_t i;
       
       for (i = 0; i < len; ++i) {
              context->state = (context->state << 8) ^ crc32_table[(context->state >> 24) ^ (input[i] & 0xff)];
       }
}