summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--ext/openssl/lib/openssl/digest.rb11
-rw-r--r--ext/openssl/ossl_digest.c11
3 files changed, 29 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 6d1f9f3b4b..535c6a4281 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Aug 25 09:25:48 2011 Eric Hodel <drbrain@segment7.net>
+
+ * ext/openssl/ossl_digest.c: Document OpenSSL::Digest::digest and add
+ an example to OpenSSL::Digest. Patch by Sylvain Daubert.
+ [Ruby 1.9 - Bug #5166]
+ * ext/openssl/lib/openssl/digest.rb (module OpenSSL): ditto
+
Thu Aug 25 08:19:43 2011 Koichi Sasada <ko1@atdot.net>
* vm.c (vm_make_env_each): work around to solve Bug #2729.
diff --git a/ext/openssl/lib/openssl/digest.rb b/ext/openssl/lib/openssl/digest.rb
index d841fef242..40fc08066b 100644
--- a/ext/openssl/lib/openssl/digest.rb
+++ b/ext/openssl/lib/openssl/digest.rb
@@ -22,6 +22,17 @@ module OpenSSL
alg += %w(SHA224 SHA256 SHA384 SHA512)
end
+ # Return the +data+ hash computed with +name+ Digest. +name+ is either the
+ # long name or short name of a supported digest algorithm.
+ #
+ # === Examples
+ #
+ # OpenSSL::Digest.digest("SHA256, "abc")
+ #
+ # which is equivalent to:
+ #
+ # OpenSSL::Digest::SHA256.digest("abc")
+
def self.digest(name, data)
super(data, name)
end
diff --git a/ext/openssl/ossl_digest.c b/ext/openssl/ossl_digest.c
index ab165c4a84..8fd6b75c36 100644
--- a/ext/openssl/ossl_digest.c
+++ b/ext/openssl/ossl_digest.c
@@ -403,6 +403,17 @@ Init_ossl_digest()
* sha256 << data2
* sha256 << data3
* digest = sha256.digest
+ *
+ * === Reuse a Digest instance
+ *
+ * data1 = File.read('file1')
+ * sha256 = OpenSSL::Digest::SHA256.new
+ * digest1 = sha256.digest(data1)
+ *
+ * data2 = File.read('file2')
+ * sha256.reset
+ * digest2 = sha256.digest(data2)
+ *
*/
cDigest = rb_define_class_under(mOSSL, "Digest", rb_path2class("Digest::Class"));
/* Document-class: OpenSSL::Digest::DigestError