Skip to content

Commit

Permalink
fix wasm compatibility #13691
Browse files Browse the repository at this point in the history
  • Loading branch information
threez committed Jul 24, 2023
1 parent bb0d62f commit a626e5a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/uuid.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
require "time"
require "io"
require "digest/sha1"
require "digest/md5"
{% if flag?(:without_openssl) %}
require "crystal/digest/sha1"
require "crystal/digest/md5"
{% else %}
require "digest/sha1"
require "digest/md5"
{% end %}

# Represents a UUID (Universally Unique IDentifier).
#
Expand Down Expand Up @@ -276,7 +281,8 @@ struct UUID
# * `name`: The name used to generate the UUID, it can be a string of any size.
# * `namespace`: Specifies the type of the name, usually one of `Namespace`
def self.v3(name : String, namespace : UUID) : self
hash = Digest::MD5.digest do |ctx|
klass = {% if flag?(:without_openssl) %}::Crystal::Digest::MD5{% else %}::Digest::MD5{% end %}
hash = klass.digest do |ctx|
ctx.update namespace.bytes
ctx.update name
end
Expand All @@ -296,7 +302,8 @@ struct UUID
# * `name`: The name used to generate the UUID, it can be a string of any size.
# * `namespace`: Specifies the type of the name, usually one of `Namespace`
def self.v5(name : String, namespace : UUID) : self
hash = Digest::SHA1.digest do |ctx|
klass = {% if flag?(:without_openssl) %}::Crystal::Digest::SHA1{% else %}::Digest::SHA1{% end %}
hash = klass.digest do |ctx|
ctx.update namespace.bytes
ctx.update name
end
Expand Down

0 comments on commit a626e5a

Please sign in to comment.