Back to index

php5  5.3.10
Functions | Variables
hash_crc32.c File Reference
#include "php_hash.h"
#include "php_hash_crc32.h"
#include "php_hash_crc32_tables.h"

Go to the source code of this file.

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 void PHP_CRC32BFinal (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)

Variables

const php_hash_ops php_hash_crc32_ops
const php_hash_ops php_hash_crc32b_ops

Function Documentation

PHP_HASH_API void PHP_CRC32BFinal ( unsigned char  digest[4],
PHP_CRC32_CTX context 
)

Definition at line 59 of file hash_crc32.c.

{
       context->state=~context->state;
       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;
}
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)];
       }
}

Variable Documentation