Digest.rb

require ‘digest/sha2’ e$B$Ne(B sha2 e$B$,$I$&$bM>7W$K;W$($k$N$G!"e(B
require ‘digest’ e$B$G:Q$`$h$&!“0J2<$N$h$&$Je(B digest.rb e$B$rIU$1$Fe(B
e$B$*$/$H$$$$$N$G$O$J$$$+$H;W$C$?$s$G$9$,!”$I$&$G$7$g$&e(B?

module Digest
autoload “MD5”, “digest/md5”
autoload “RMD160”, “digest/rmd160”
autoload “SHA1”, “digest/sha1”
autoload “SHA256”, “digest/sha2”
autoload “SHA384”, “digest/sha2”
autoload “SHA512”, “digest/sha2”
end

e$B$J$*!"e(Bdigest.rb e$B$K$Oe(B Digest::Base.hexdigest_file
e$B$J$I$rIU$1e(B
e$B$k>l=j$H$7$F$N0UL#$b9M$($F$$$^$9!#e(B

e$B!!5W$7$V$j$KI|5"!#e(B

At Sun, 4 Jun 2006 17:34:00 +0900,
Tanaka A. wrote:

autoload “SHA512”, “digest/sha2”
end

e$B!!;?@.$G$9!#e(B1.9 e$B$KF~$l$^$7$g$&!#e(B

e$B$J$*!"e(Bdigest.rb e$B$K$Oe(B Digest::Base.hexdigest_file e$B$J$I$rIU$1e(B
e$B$k>l=j$H$7$F$N0UL#$b9M$($F$$$^$9!#e(B

e$B!!$3$l$b$h$/;H$&$N$GM_$7$$$G$9$h$M!#e(B

e$B!!e(BIO e$B$r<h$k$b$N$O$=$s$J$K<{MW$O$J$$$+$J!)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”

In article [email protected],
“Akinori MUSHA” [email protected] writes:

e$B!!;?@.$G$9!#e(B1.9 e$B$KF~$l$^$7$g$&!#e(B

e$B$$$l$^$7$?!#e(B

e$B$J$*!"e(Bdigest.rb e$B$K$Oe(B Digest::Base.hexdigest_file e$B$J$I$rIU$1e(B
e$B$k>l=j$H$7$F$N0UL#$b9M$($F$$$^$9!#e(B

e$B!!$3$l$b$h$/;H$&$N$GM_$7$$$G$9$h$M!#e(B

e$B$O$$!#e(B

e$B$3$l$K$D$$$F$O$$$m$$$m$H9M$($?7k2L!“e(BAPI e$B$O%^%K%e%”%k$K:$C$Fe(B
e$B$$$ke(B Digest::Base.open e$B$,$@$$$?$$$$$$$H;W$&$N$G$9$,!"e(Bclose
e$B$HBP$K$J$i$J$$e(B open e$B$O$A$g$C$H$J$s$J$N$G!“e(Bfile
e$B$H$$$&L>A0$Ke(B
e$B$7$F!”$3$s$J46$8$G$I$&$+$H;W$$$^$9!#e(B

Index: ext/digest/lib/digest.rb

RCS file: /src/ruby/ext/digest/lib/digest.rb,v
retrieving revision 1.1
diff -u -p -r1.1 digest.rb
— ext/digest/lib/digest.rb 13 Sep 2006 16:03:23 -0000 1.1
+++ ext/digest/lib/digest.rb 13 Sep 2006 16:20:37 -0000
@@ -5,4 +5,17 @@ module Digest
autoload “SHA256”, “digest/sha2”
autoload “SHA384”, “digest/sha2”
autoload “SHA512”, “digest/sha2”
+

  • class Base
  • def self.file(name)
  •  digest = self.new
    
  •  open(name) {|f|
    
  •    buf = ""
    
  •    while f.read(16384, buf)
    
  •      digest.update buf
    
  •    end
    
  •  }
    
  •  digest
    
  • end
  • end
    end

e$B$J$e(B RubyKaigi2006 e$B$NH/I=;qNA$N:G8e$K$b$3$l$rA$s$@M}M3$,e(B

e$B$$$/$i$+=q$$$F$"$j$^$9!#e(B

e$B!!e(BIO e$B$r<h$k$b$N$O$=$s$J$K<{MW$O$J$$$+$J!)e(B

[ruby-talk:116637] e$B$K$=$&$$$&Ds0F$,$"$j$^$9$,!"MQES$H$7$F$"e(B
e$B$2$i$l$F$$$k$N$O7k6I%U%!%$%k$rFI$`$H$$$&OC$J$s$G$9$h$M$'!#e(B

e$B%U%!%$%k0J30$Ne(B IO
e$B$@$H!“FI$`$H$J$/$J$C$A$c$&$+$b$7$l$J$$$N$G!“e(B
e$B$=$&$9$k$H%G!<%?$=$N$b$N$O$$$i$J$$$s$@$1$Ie(B digest e$B$OM_$7$$$He(B
e$B$$$&MQES$K$J$j$^$9$,!”$=$l$C$F$5$9$,$K$h$/$”$k$H$O8@$$$,$?$$e(B
e$B$h$&$J!#e(B

e$B$H$j$"$($:!“0lHVBg$-$J<{MW$O%U%!%$%k$rFI$`$H$$$&OC$J$N$G!”<!e(B
e$B$KBg$-$J<{MW$K$D$$$F9M$($k$N$O$7$P$i$/;H$C$F$+$i$G$$$$$s$8$ce(B
e$B$J$$$G$9$+$M!#e(B

At Thu, 14 Sep 2006 01:31:18 +0900,
Tanaka A. wrote:

In article [email protected],
“Akinori MUSHA” [email protected] writes:

e$B!!;?@.$G$9!#e(B1.9 e$B$KF~$l$^$7$g$&!#e(B

e$B$$$l$^$7$?!#e(B

e$B!!$U$H8+$l$P!"e(B md5.rb e$B$He(B sha1.rb
e$B$,$^$@;D$C$F$$$^$7$?!#e(B

e$B!!e(B1.9 e$B$Ge(BDigest
e$B$N;H$$>!<j$,JQ$o$k$3$H$G$9$7!“$3$N%?%$%_%s%0$Ge(B
(1.9 e$B$+$i$Oe(B)e$B>C$7$F$9$C$-$j$7$?$$$N$G$9$,!”$I$&$G$7$g$&$+!#e(B

e$B$3$l$K$D$$$F$O$$$m$$$m$H9M$($?7k2L!“e(BAPI e$B$O%^%K%e%”%k$K:$C$Fe(B
e$B$$$ke(B Digest::Base.open e$B$,$@$$$?$$$$$$$H;W$&$N$G$9$,!"e(Bclose
e$B$HBP$K$J$i$J$$e(B open e$B$O$A$g$C$H$J$s$J$N$G!“e(Bfile e$B$H$$$&L>A0$Ke(B
e$B$7$F!”$3$s$J46$8$G$I$&$+$H;W$$$^$9!#e(B

e$B!!e(BFile.open() e$B$+$ie(B open()
e$B$K$7$?$N$O!“e(BURIe$B$d%Q%$%W$b<u$1F~$l$ke(B
e$B0U?^$G$7$g$&$+!#e(Bfile()
e$B$H$$$&L>A0$J$i$P!”%U%!%$%kL>0J30$rEO$9e(B
e$B;H$$J}$r$5$l$k$3$H$K$O0cOB46$r3P$($^$9!#e(B

e$B$J$e(B RubyKaigi2006 e$B$NH/I=;qNA$N:G8e$K$b$3$l$rA$s$@M}M3$,e(B

e$B$$$/$i$+=q$$$F$"$j$^$9!#e(B

e$B!!%A%'%C%/$7$^$7$?!#;qNA$H2;@<$,$9$Y$FB7$C$F$$$F3Z$7$a$^$7$?!#e(B

e$B$H$j$"$($:!“0lHVBg$-$J<{MW$O%U%!%$%k$rFI$`$H$$$&OC$J$N$G!”<!e(B
e$B$KBg$-$J<{MW$K$D$$$F9M$($k$N$O$7$P$i$/;H$C$F$+$i$G$$$$$s$8$ce(B
e$B$J$$$G$9$+$M!#e(B

e$B!!$O$$!"$=$&;W$$$^$9!#e(B

e$B!!>e$N%a%=%C%IL>$N7o$Ge(B read()
e$B$H$$$&$N$r;W$$$D$-!"$=$NL>A0$+$ie(B
e$B5U;;$7$F%U%!%$%kL>$^$?$Oe(B IO
e$B$r<h$k;EMM$O$I$&$+$H;W$C$?$N$G$9$,!“e(B
e$B6D$kDL$j!”;H$$$?$$%7!<%s$,$J$+$J$+;W$$Ib$+$P$J$$$N$GJ]N1$7$^$9!#e(B

e$B!!e(Bopen() e$B$N0z?t$K$J$k$b$N0lHL$de(B IO
e$B$r0z?t$K<h$k%a%=%C%I$,I,MW$He(B
e$B$J$C$?$i!"L>A0$H$H$b$K$^$?9M$($k$3$H$K$7$^$7$g$&!#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”

In article [email protected],
“Akinori MUSHA” [email protected] writes:

e$B!!$U$H8+$l$P!"e(B md5.rb e$B$He(B sha1.rb e$B$,$^$@;D$C$F$$$^$7$?!#e(B

e$B!!e(B1.9 e$B$Ge(BDigest e$B$N;H$$>!<j$,JQ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ext/digest/lib/digest.rb,v
retrieving revision 1.1
diff -u -p -r1.1 digest.rb
— ext/digest/lib/digest.rb 13 Sep 2006 16:03:23 -0000 1.1
+++ ext/digest/lib/digest.rb 13 Sep 2006 23:41:36 -0000
@@ -5,4 +5,17 @@ module Digest
autoload “SHA256”, “digest/sha2”
autoload “SHA384”, “digest/sha2”
autoload “SHA512”, “digest/sha2”
+

  • class Base
  • def self.file(name)
  •  digest = self.new
    
  •  File.open(name) {|f|
    
  •    buf = ""
    
  •    while f.read(16384, buf)
    
  •      digest.update buf
    
  •    end
    
  •  }
    
  •  digest
    
  • end
  • end
    end

In article [email protected],
“Akinori MUSHA” [email protected] writes:

e$B!!e(BRuby e$B$N3+H/%Z!<%9$r$_$k$H!">e0L8_49@-$OFs7ONsJ]$F$P==J,$+$Je(B
e$B$H$$$&8+J}$r$7$F$$$^$9!#:#e(B 1.4 e$B$H$N8_49@-$r9M$($kI,MW@-$O8B$je(B
e$B$J$/Gv$$$H;W$$$^$9$7!#e(B

e$B!!>/$7MM;R$r8+$F7h$a$^$9!#e(B

e$B;W$$IU$$$?$N$G$9$,!“e(BMD5 e$B$He(B SHA1
e$B$r;H$$$d$9$$$H$3$m$K$*$$$F$*e(B
e$B$/$N$O$b$O$d320-$G$”$k!"$H$$$&M}M3$N<gD%$O2DG=$+$b$7$l$^$;$s!#e(B

e$B%3%j%8%g%s$NOC$,=P$F$$$^$9$+$i!"%;%-%e%j%F%#E*$JOC$H$7$F$*A&e(B
e$B$a$GL5$$$N$O3N$+$G$9$h$M!#e(B

e$B$H$9$k$H!"e(BFile.open e$B$KLa$7$F$3$s$J$+$s$8$G$7$g$&$+!#e(B

e$B!!$3$l$G$*4j$$$7$^$9!#e(B

e$BF~$l$^$7$?!#e(B

e$B@>;3OB9-$G$9!#e(B

On Thu, 14 Sep 2006 08:57:29 +0900
[email protected](Tanaka A.) said:

  •  File.open(name) {|f|
    

e$B%P%$%J%j%b!<%I$K$7$?J}$,NI$$$N$G$O$J$$$G$7$g$&$+e(B?

In article [email protected],
Kazuhiro NISHIYAMA [email protected] writes:

e$B%P%$%J%j%b!<%I$K$7$?J}$,NI$$$N$G$O$J$$$G$7$g$&$+e(B?

e$B$J$k$[$I!#$=$l$O$?$7$+$K!#e(B

At Thu, 14 Sep 2006 08:57:29 +0900,
Tanaka A. wrote:

In article [email protected],
“Akinori MUSHA” [email protected] writes:

e$B!!$U$H8+$l$P!"e(B md5.rb e$B$He(B sha1.rb e$B$,$^$@;D$C$F$$$^$7$?!#e(B

e$B!!e(B1.9 e$B$Ge(BDigest e$B$N;H$$>!<j$,JQ$o$k$3$H$G$9$7!“$3$N%?%$%_%s%0$Ge(B
(1.9 e$B$+$i$Oe(B)e$B>C$7$F$9$C$-$j$7$?$$$N$G$9$,!”$I$&$G$7$g$&$+!#e(B

e$B4pK\E*$K;?@.$G$O$“$k$N$G$9$,!”;H$$>!<j$,0-$/$J$ke(B (featuree$BL>e(B
e$B$,D9$/$J$ke(B) e$BJ}8~$NJQ99$J$N$G!"5$$KF~$i$J$$?M$b$$$=$&$G$9$M!#e(B

e$B!!e(BRuby
e$B$N3+H/%Z!<%9$r$_$k$H!">e0L8_49@-$OFs7ONsJ]$F$P==J,$+$Je(B
e$B$H$$$&8+J}$r$7$F$$$^$9!#:#e(B 1.4
e$B$H$N8_49@-$r9M$($kI,MW@-$O8B$je(B
e$B$J$/Gv$$$H;W$$$^$9$7!#e(B

e$B!!>/$7MM;R$r8+$F7h$a$^$9!#e(B

e$B!!e(Bopen() e$B$N0z?t$K$J$k$b$N0lHL$de(B IO e$B$r0z?t$K<h$k%a%=%C%I$,I,MW$He(B
e$B$J$C$?$i!"L>A0$H$H$b$K$^$?9M$($k$3$H$K$7$^$7$g$&!#e(B

e$B$H$9$k$H!"e(BFile.open e$B$KLa$7$F$3$s$J$+$s$8$G$7$g$&$+!#e(B

e$B!!$3$l$G$*4j$$$7$^$9!#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”