Sha256: 701089248a14886de5b4ab70850856a9407fa94aaeb3480cb74ee7b551850e17

Contents?: true

Size: 375 Bytes

Versions: 12

Compression:

Stored size: 375 Bytes

Contents

require 'digest'

module InlineSvg
  class IdGenerator
    class Randomness
      require "securerandom"
      def self.call
        SecureRandom.hex(10)
      end
    end

    def self.generate(base, salt, randomness: Randomness)
      bytes = Digest::SHA1.digest("#{base}-#{salt}-#{randomness.call}")
      'a' + Digest.hexencode(bytes).to_i(16).to_s(36)
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
inline_svg-1.10.0 lib/inline_svg/id_generator.rb
inline_svg-1.9.0 lib/inline_svg/id_generator.rb
inline_svg-1.8.0 lib/inline_svg/id_generator.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/inline_svg-1.7.2/lib/inline_svg/id_generator.rb
inline_svg-1.7.2 lib/inline_svg/id_generator.rb
inline_svg-1.7.1 lib/inline_svg/id_generator.rb
inline_svg-1.7.0 lib/inline_svg/id_generator.rb
inline_svg-1.6.0 lib/inline_svg/id_generator.rb
inline_svg-1.5.2 lib/inline_svg/id_generator.rb
inline_svg-1.5.1 lib/inline_svg/id_generator.rb
inline_svg-1.5.0 lib/inline_svg/id_generator.rb
inline_svg-1.4.0 lib/inline_svg/id_generator.rb