Sha256: cacbd25b564072616b09b7a38f32dea5c269e26bd6677f2d51d21b23590105e7

Contents?: true

Size: 309 Bytes

Versions: 21

Compression:

Stored size: 309 Bytes

Contents

# frozen_string_literal: true

# addon for the Atome class
class Atome
  def calculate_sha(string)
    if RUBY_ENGINE.downcase == 'opal' || 'wasm32-wasi'
      # `sha256(#{string})`
      js_code = "sha256('#{string}')"
      JS.eval(js_code)
    else
      Digest::SHA256.hexdigest(string)
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
atome-0.5.6.1.4 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.6.1.1 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.6.1.0 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.6.0.4 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.6.0.3 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.6.0.2 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.9.1 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.8.7 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.8.5 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.8.1 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.7.7 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.7.5 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.7.3 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.7.1 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.7.0 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.6.9 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.6.8 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.6.7.9 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.6.6 lib/platform_specific/opal/extensions/sha.rb
atome-0.5.5.6.5 lib/platform_specific/opal/extensions/sha.rb