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)


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


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

     ADLER32Init(ADLER32_CTX *ctx);

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

     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);


     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-

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


     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);

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

           /* print the digest as one long sedecimal value */
           for (n = 0; n < ADLER32_DIGEST_LENGTH; n++)
                   printf("%02X", result[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));


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


     The ADLER32 functions appeared in MirBSD #10.


     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