diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-08-13 05:37:52 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-08-13 05:37:52 +0000 |
commit | 0a64817fb80016030c03518fb9459f63c11605ea (patch) | |
tree | 3ea2e607f9ea08c56830ef7b803cd259e3d67c7f /ext/md5 | |
parent | 210367ec889f5910e270d6ea2c7ddb8a8d939e61 (diff) | |
download | ruby-0a64817fb80016030c03518fb9459f63c11605ea.tar.gz |
remove marshal/gtk/kconv
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/md5')
-rw-r--r-- | ext/md5/MANIFEST | 3 | ||||
-rw-r--r-- | ext/md5/depend | 2 | ||||
-rw-r--r-- | ext/md5/md5.txt | 38 | ||||
-rw-r--r-- | ext/md5/md5.txt.jp (renamed from ext/md5/md5.doc) | 3 | ||||
-rw-r--r-- | ext/md5/md5init.c | 28 |
5 files changed, 67 insertions, 7 deletions
diff --git a/ext/md5/MANIFEST b/ext/md5/MANIFEST index e4f0004b4a..8057ebb06c 100644 --- a/ext/md5/MANIFEST +++ b/ext/md5/MANIFEST @@ -1,6 +1,7 @@ MANIFEST depend -md5.doc +md5.txt +md5.txt.jp md5.h md5c.c md5init.c diff --git a/ext/md5/depend b/ext/md5/depend index abb2a47419..c99f78ee90 100644 --- a/ext/md5/depend +++ b/ext/md5/depend @@ -1,2 +1,2 @@ md5c.o: md5c.c md5.h -md5init.o: md5init.c $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h md5.h +md5init.o: md5init.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h md5.h diff --git a/ext/md5/md5.txt b/ext/md5/md5.txt new file mode 100644 index 0000000000..0eca7c9025 --- /dev/null +++ b/ext/md5/md5.txt @@ -0,0 +1,38 @@ +.\" md5.doc - -*- Indented-Text -*- created at: Fri Aug 2 12:01:27 JST 1996 + +** MD5(Class) + +A class to implement MD5 Message-Digest Algorithm by RSA Data +Security, Inc., described in RFC1321. + +SuperClass: Object + +Class Methods: + + new([str]) + md5([str]) + + creates a new MD5 object. If a string argument is given, it + is added to the object. (see update.) + +Methods: + + clone + + copies the MD5 object. + + digest + + returns have value of the added strings as a 16 bytes string. + + update(str) + + Update the MD5 object with the string. Repeated calls are + equivalent to a single call with the concatenation of all the + arguments, i.e. m.update(a); m.update(b) is equivalent to + m.update(a+b). + +------------------------------------------------------- +Local variables: +fill-column: 70 +end: diff --git a/ext/md5/md5.doc b/ext/md5/md5.txt.jp index 2203404602..a1451f1175 100644 --- a/ext/md5/md5.doc +++ b/ext/md5/md5.txt.jp @@ -28,7 +28,8 @@ Methods: update(str) - keyをキーとする値を返す. + MD5オブジェクトに文字列を追加する。複数回updateを呼ぶことは文 + 字列を連結してupdateを呼ぶことと等しい. ------------------------------------------------------- Local variables: diff --git a/ext/md5/md5init.c b/ext/md5/md5init.c index a825f96d47..552a407c6d 100644 --- a/ext/md5/md5init.c +++ b/ext/md5/md5init.c @@ -29,8 +29,9 @@ md5_update(obj, str) Data_Get_Struct(obj, MD5_CTX, md5); MD5Update(md5, str->ptr, str->len); - return Qnil; + return obj; } + static VALUE md5_digest(obj) VALUE obj; @@ -46,10 +47,28 @@ md5_digest(obj) } static VALUE +md5_hexdigest(obj) + VALUE obj; +{ + MD5_CTX *md5, ctx; + unsigned char digest[16]; + char buf[33]; + int i; + + Data_Get_Struct(obj, MD5_CTX, md5); + ctx = *md5; + MD5Final(digest, &ctx); + + for (i=0; i<16; i++) { + sprintf(buf+i*2, "%02x", digest[i]); + } + return rb_str_new(buf, 32); +} + +static VALUE md5_clone(obj) VALUE obj; { - VALUE clone; MD5_CTX *md5, *md5_new; Data_Get_Struct(obj, MD5_CTX, md5); @@ -65,7 +84,6 @@ md5_new(argc, argv, class) VALUE* argv; VALUE class; { - int i; VALUE arg, obj; MD5_CTX *md5; @@ -77,11 +95,12 @@ md5_new(argc, argv, class) if (!NIL_P(arg)) { md5_update(obj, arg); } - rb_obj_call_init(obj); + rb_obj_call_init(obj, argc, argv); return obj; } +void Init_md5() { cMD5 = rb_define_class("MD5", rb_cObject); @@ -90,5 +109,6 @@ Init_md5() rb_define_method(cMD5, "update", md5_update, 1); rb_define_method(cMD5, "digest", md5_digest, 0); + rb_define_method(cMD5, "hexdigest", md5_hexdigest, 0); rb_define_method(cMD5, "clone", md5_clone, 0); } |