From 55ef220fe08ddaafdc874f423e92d6d23bddf1eb Mon Sep 17 00:00:00 2001 From: gotoyuzo Date: Mon, 8 May 2006 00:12:00 +0000 Subject: * ext/openssl/extconf.rb: add check for OBJ_NAME_do_all_sorted. * ext/openssl/ossl_cipher.c (ossl_s_ciphers): new method OpenSSL::Cipher.ciphers. it returns all the cipher names. * ext/openssl/ossl_cipher.c (ossl_cipher_init): refine warning message. * ext/openssl/lib/openssl/cipher.rb: reimplement without eval() and add constants AES128, AES192, AES256. [ruby-dev:28610] * ext/openssl/lib/openssl/digest.rb: reimplement without eval(). * test/openssl/test_cipher.rb, test_digest: fix about reimplemented features. * sample/openssl/cipher.rb: rewrite all. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/lib/openssl/digest.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'ext/openssl/lib/openssl/digest.rb') diff --git a/ext/openssl/lib/openssl/digest.rb b/ext/openssl/lib/openssl/digest.rb index 5745661c3c..b3e4484805 100644 --- a/ext/openssl/lib/openssl/digest.rb +++ b/ext/openssl/lib/openssl/digest.rb @@ -26,22 +26,22 @@ module OpenSSL alg += %w(SHA224 SHA256 SHA384 SHA512) end - alg.each{|digest| - self.module_eval(<<-EOD) - class #{digest} < Digest - def initialize(data=nil) - super(\"#{digest}\", data) + alg.each{|name| + klass = Class.new(Digest){ + define_method(:initialize){|*data| + if data.length > 1 + raise ArgumentError, + "wrong number of arguments (#{data.length} for 1)" end - - def #{digest}::digest(data) - Digest::digest(\"#{digest}\", data) - end - - def #{digest}::hexdigest(data) - Digest::hexdigest(\"#{digest}\", data) - end - end - EOD + super(name, data.first) + } + } + singleton = (class <