mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
ba9207f301
As mentioned in https://github.com/rails/rails/pull/40770#issuecomment-748347066 we should default to SHA256 where SHA1 is used today. This switches over the ActiveSupport::Digest to use SHA256 for new applications. It also updates the constants to always refer to and use the OpenSSL constants as well, as also discussed in that PR.
22 lines
512 B
Ruby
22 lines
512 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "openssl"
|
|
|
|
module ActiveSupport
|
|
class Digest #:nodoc:
|
|
class <<self
|
|
def hash_digest_class
|
|
@hash_digest_class ||= OpenSSL::Digest::MD5
|
|
end
|
|
|
|
def hash_digest_class=(klass)
|
|
raise ArgumentError, "#{klass} is expected to implement hexdigest class method" unless klass.respond_to?(:hexdigest)
|
|
@hash_digest_class = klass
|
|
end
|
|
|
|
def hexdigest(arg)
|
|
hash_digest_class.hexdigest(arg)[0...32]
|
|
end
|
|
end
|
|
end
|
|
end
|