mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/digest/lib/digest/hmac.rb (Digest::HMAC::update): Minor
optimization. * ext/digest/digest.c (rb_digest_instance_equal): Allow comparing a digest instance with another of a different class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
70aa19b6c6
commit
dd937ba9dc
3 changed files with 14 additions and 5 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Wed Nov 1 02:22:31 2006 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* ext/digest/lib/digest/hmac.rb (Digest::HMAC::update): Minor
|
||||||
|
optimization.
|
||||||
|
|
||||||
|
* ext/digest/digest.c (rb_digest_instance_equal): Allow comparing
|
||||||
|
a digest instance with another of a different class.
|
||||||
|
|
||||||
Tue Oct 31 17:03:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Tue Oct 31 17:03:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* time.c (time_dup): duplicate the class of original time.
|
* time.c (time_dup): duplicate the class of original time.
|
||||||
|
|
|
@ -286,16 +286,16 @@ rb_digest_instance_inspect(VALUE self)
|
||||||
* digest_obj == string -> boolean
|
* digest_obj == string -> boolean
|
||||||
*
|
*
|
||||||
* If a string is given, checks whether it is equal to the hex-encoded
|
* If a string is given, checks whether it is equal to the hex-encoded
|
||||||
* hash value of the digest object. If another instance of the same
|
* hash value of the digest object. If another digest instance is
|
||||||
* digest class is given, checks whether they have the same hash
|
* given, checks whether they have the same hash value. Otherwise
|
||||||
* value. Otherwise returns false.
|
* returns false.
|
||||||
*/
|
*/
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_digest_instance_equal(VALUE self, VALUE other)
|
rb_digest_instance_equal(VALUE self, VALUE other)
|
||||||
{
|
{
|
||||||
VALUE str1, str2;
|
VALUE str1, str2;
|
||||||
|
|
||||||
if (rb_obj_class(self) == rb_obj_class(other)) {
|
if (rb_obj_is_kind_of(other, rb_mDigest_Instance) == Qtrue) {
|
||||||
str1 = rb_digest_instance_digest(0, 0, self);
|
str1 = rb_digest_instance_digest(0, 0, self);
|
||||||
str2 = rb_digest_instance_digest(0, 0, other);
|
str2 = rb_digest_instance_digest(0, 0, other);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -67,7 +67,8 @@ module Digest
|
||||||
end
|
end
|
||||||
|
|
||||||
def update(text)
|
def update(text)
|
||||||
@md.reset.update(@opad + @md.digest(@ipad + text))
|
# @md is reset when digest() returns
|
||||||
|
@md.update(@opad + @md.digest(@ipad + text))
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue