Project

General

Profile

Actions

Feature #6819

closed

OpenSSL::Digest.new should return an instance of the chosen subclass

Added by drbrain (Eric Hodel) over 12 years ago. Updated over 12 years ago.

Status:
Closed
Target version:
[ruby-core:46908]

Description

=begin
(({OpenSSL::Digest.new})) allows you to create a digest given the digest name:

digester = OpenSSL::Digest.new "SHA1"
digester.update "hello"

The digester returned is of class (({OpenSSL::Digest})) regardless of the input type.

I would like this changed so that it returns the specific subclass of (({OpenSSL::Digest})):

digester = OpenSSL::Digest.new "SHA1"
digester.class #=> OpenSSL::Digest::SHA1

When multiple digests are created this makes it easier to distinguish the type of digest you are working with.

This will also make (({OpenSSL::Digest.new})) behave similarly to (({Digest})):

digester = Digest("SHA1").new
digester.class #=> Digest::SHA1

=end


Files

openssl.digest.module_function.patch (1.08 KB) openssl.digest.module_function.patch drbrain (Eric Hodel), 08/02/2012 07:30 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0