* ext/openssl/lib/openssl/digest.rb

test/openssl/test_digest.rb: Add Digest module function to OpenSSL
  module and test it. Patch provided by Eric Hodel.
  [ruby-core:46908][Feature #6819]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
emboss 2012-08-02 01:58:49 +00:00
parent cc59a581f1
commit df05bd2c82
3 changed files with 32 additions and 0 deletions

View File

@ -1,3 +1,10 @@
Thu Aug 2 10:51:12 2012 Martin Bosslet <Martin.Bosslet@gmail.com>
* ext/openssl/lib/openssl/digest.rb
test/openssl/test_digest.rb: Add Digest module function to OpenSSL
module and test it. Patch provided by Eric Hodel.
[ruby-core:46908][Feature #6819]
Wed Aug 1 22:29:12 2012 Benoit Daloze <eregontp@gmail.com>
ext/digest/digest.c (hexencode_str_new): return an ASCII string

View File

@ -68,5 +68,22 @@ module OpenSSL
end
end # Digest
# Returns a Digest subclass by +name+.
#
# require 'openssl'
#
# OpenSSL::Digest("MD5")
# # => OpenSSL::Digest::MD5
#
# Digest("Foo")
# # => NameError: wrong constant name Foo
def Digest(name)
OpenSSL::Digest.const_get(name)
end
module_function :Digest
end # OpenSSL

View File

@ -103,6 +103,14 @@ class OpenSSL::TestDigest < Test::Unit::TestCase
end
end
def test_openssl_digest
assert_equal OpenSSL::Digest::MD5, OpenSSL::Digest("MD5")
assert_raises NameError do
OpenSSL::Digest("no such digest")
end
end
private
def check_digest(oid)