MirBSD manpage: adler32(3), ADLER32Data(3), ADLER32End(3), ADLER32File(3), ADLER32FileChunk(3), ADLER32Final(3), ADLER32Init(3), ADLER32Update(3)

ADLER32(3)                 BSD Programmer's Manual                  ADLER32(3)

NAME

     ADLER32Init, ADLER32Update, ADLER32Final, ADLER32End, ADLER32File,
     ADLER32FileChunk, ADLER32Data - calculate the ADLER32 checksum

SYNOPSIS

     #include <sys/types.h>
     #include <adler32.h>

     void
     ADLER32Init(ADLER32_CTX *ctx);

     void
     ADLER32Update(ADLER32_CTX *ctx, const uint8_t *data, size_t noctets);

     void
     ADLER32Final(uint8_t digest[ADLER32_DIGEST_LENGTH], ADLER32_CTX *ctx);

     char *
     ADLER32End(ADLER32_CTX *ctx, char *digest);

     char *
     ADLER32File(const char *filename, char *digest);

     char *
     ADLER32FileChunk(const char *filename, char *digest, off_t offset,
             off_t length);

     char *
     ADLER32Data(const uint8_t *data, size_t len, char *digest);

DESCRIPTION

     The ADLER32 functions implement the 32-bit ADLER32 cyclic redundancy
     checksum. They share a similar API to the md5(3) interface.

     The ADLER32Init() function initialises a ADLER32_CTX context for use with
     ADLER32Update() and ADLER32Final(). The ADLER32Update() function adds
     (condenses) data of length noctets to the context. ADLER32Final() is
     called after processing and stores a message digest in the digest parame-
     ter.

     For a description of the other functions, please refer e.g. the rmd160(3)
     manual page.

EXAMPLES

     The follow code fragment will calculate the checksum for the string
     "abc", which is "024D0127".

           ADLER32_CTX context;
           uint8_t result[ADLER32_DIGEST_LENGTH];
           const char buf[] = "abc";
           size_t n = strlen(buf);

           ADLER32Init(&context);
           ADLER32Update(&context, buf, n);
           ADLER32Final(result, &context);

           /* print the digest as one long sedecimal value */
           printf("0x");
           for (n = 0; n < ADLER32_DIGEST_LENGTH; n++)
                   printf("%02X", result[n]);
           putchar('\n');

     Alternately, the helper functions could be used in the following way:

           ADLER32_CTX context;
           uint8_t output[ADLER32_DIGEST_STRING_LENGTH];
           const char buf[] = "abc";

           printf("0x%s\n", ADLER32Data(buf, strlen(buf), output));

SEE ALSO

     cksum(1), compress(3), md4(3), md5(3), rmd160(3), sfv(3), sha1(3),
     sha2(3), suma(3), tiger(3), whirlpool(3)

HISTORY

     The ADLER32 functions appeared in MirBSD #10.

AUTHORS

     This implementation of ADLER32 was written by Thorsten Glaser
     <tg@mirbsd.de> as a size-optimised version of the zlib Adler-32 checksum.

     The ADLER32End(), ADLER32File(), ADLER32FileChunk(), and ADLER32Data()
     helper functions are derived from code written by Poul-Henning Kamp.

MirBSD #10-current            September 4, 2020                              1

Generated on 2022-12-24 01:00:14 by $MirOS: src/scripts/roff2htm,v 1.113 2022/12/21 23:14:31 tg Exp $ — This product includes material provided by mirabilos.

These manual pages and other documentation are copyrighted by their respective writers; their sources are available at the project’s CVSweb, AnonCVS and other mirrors. The rest is Copyright © 2002–2022 MirBSD.

This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report — diffs preferred.

Kontakt / Impressum & Datenschutzerklärung