Digest::Base#inspect

Digest::SHA256 e$B$N%$%s%9%?%s%9$H$+$re(B p e$B$GI=<($9$k$H0J2<$N$h$&e(B
e$B$Ke(B 16e$B?J$NJ8;zNs$,=P$F$-$^$9!#e(B

% ./ruby -v -rdigest -e ‘p Digest::SHA256.new’
ruby 1.9.0 (2006-09-13) [i686-linux]
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

e$B$@$$$?$$0l0U$G$"$k$H$$$o$l$l$P$=$l$O$=$&$J$N$+$b$7$l$^$;$s$,e(B
e$B$d$O$j$3$3$O0J2<$N$h$&$K$J$C$F$[$7$$$N$G$9$,!"$I$&$G$7$g$&e(B?

% ./ruby -rdigest -e ‘p Digest::SHA256.new’
#<Digest::SHA256:
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>

Index: ext/digest/digest.c

RCS file: /src/ruby/ext/digest/digest.c,v
retrieving revision 1.17
diff -u -p -r1.17 digest.c
— ext/digest/digest.c 12 Dec 2005 05:15:33 -0000 1.17
+++ ext/digest/digest.c 13 Sep 2006 17:20:19 -0000
@@ -210,6 +210,27 @@ rb_digest_base_hexdigest(VALUE self)
}

static VALUE
+rb_digest_base_inspect(VALUE self)
+{

  • algo_t *algo;
  • VALUE str;
  • char *cname;
  • algo = get_digest_base_metadata(rb_obj_class(self));
  • cname = rb_obj_classname(self);
  • /* #<Digest::Alg: xxxxx…xxxx> */
  • str = rb_str_buf_new(2 + strlen(cname) + 2 + algo->digest_len * 2 +
    1);
  • rb_str_buf_cat2(str, “#<”);
  • rb_str_buf_cat2(str, cname);
  • rb_str_buf_cat2(str, ": ");
  • rb_str_buf_append(str, rb_digest_base_hexdigest(self));
  • rb_str_buf_cat2(str, “>”);
  • return str;
    +}

+static VALUE
rb_digest_base_equal(VALUE self, VALUE other)
{
algo_t *algo;
@@ -265,6 +286,7 @@ Init_digest()
rb_define_method(cDigest_Base, “digest”, rb_digest_base_digest, 0);
rb_define_method(cDigest_Base, “hexdigest”,
rb_digest_base_hexdigest, 0);
rb_define_method(cDigest_Base, “to_s”, rb_digest_base_hexdigest,
0);

  • rb_define_method(cDigest_Base, “inspect”, rb_digest_base_inspect,
    0);
    rb_define_method(cDigest_Base, “==”, rb_digest_base_equal, 1);

    id_metadata = rb_intern(“metadata”);

At Thu, 14 Sep 2006 02:25:09 +0900,
Tanaka A. wrote:

Digest::SHA256 e$B$N%$%s%9%?%s%9$H$+$re(B p e$B$GI=<($9$k$H0J2<$N$h$&e(B
e$B$Ke(B 16e$B?J$NJ8;zNs$,=P$F$-$^$9!#e(B

e$B!!e(Binspect e$B$,$J$+$C$?$s$G$9$M!#F~$l$F$/$@$5$$!#e(B


/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

“Different eyes see different things,
Different hearts beat on different strings –
But there are times for you and me when all such things agree”