Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# ext/digest/md5/md5init.c

Go to the documentation of this file.

    00001 /* $RoughId: md5init.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
    00002 /* $Id: md5init.c 28341 2010-06-16 09:38:14Z knu $ */
    00003
    00004 #include "../digest.h"
    00005 #if defined(HAVE_OPENSSL_MD5_H)
    00006 #include "md5ossl.h"
    00007 #else
    00008 #include "md5.h"
    00009 #endif
    00010
    00011 static const rb_digest_metadata_t md5 = {
    00012     RUBY_DIGEST_API_VERSION,
    00013     MD5_DIGEST_LENGTH,
    00014     MD5_BLOCK_LENGTH,
    00015     sizeof(MD5_CTX),
    00016     (rb_digest_hash_init_func_t)MD5_Init,
    00017     (rb_digest_hash_update_func_t)MD5_Update,
    00018     (rb_digest_hash_finish_func_t)MD5_Finish,
    00019 };
    00020
    00021 /*
    00022  * A class for calculating message digests using the MD5
    00023  * Message-Digest Algorithm by RSA Data Security, Inc., described in
    00024  * RFC1321.
    00025  */
    00026 void
    00027 Init_md5()
    00028 {
    00029     VALUE mDigest, cDigest_Base, cDigest_MD5;
    00030
    00031     rb_require("digest");
    00032
    00033     mDigest = rb_path2class("Digest");
    00034     cDigest_Base = rb_path2class("Digest::Base");
    00035
    00036     cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base);
    00037
    00038     rb_ivar_set(cDigest_MD5, rb_intern("metadata"),
    00039       Data_Wrap_Struct(rb_cObject, 0, 0, (void *)&md5));
    00040 }
    00041