Skip to content

Commit

Permalink
[Truffle] Digest.hexencode
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed May 18, 2015
1 parent 4800d8f commit 78953ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
13 changes: 7 additions & 6 deletions lib/ruby/truffle/truffle/digest.rb
Expand Up @@ -33,7 +33,7 @@ def digest(message=NO_MESSAGE)
end

def hexdigest(message=NO_MESSAGE)
digest(message).unpack('H*').first
Digest.hexencode(digest(message))
end

alias_method :to_s, :hexdigest
Expand Down Expand Up @@ -91,7 +91,6 @@ def hexdigest(message)
end

class MD5 < Base

extend BaseFunctions

def initialize
Expand All @@ -105,7 +104,6 @@ def block_length
end

class SHA1 < Base

extend BaseFunctions

def initialize
Expand All @@ -119,7 +117,6 @@ def block_length
end

class SHA256 < Base

extend BaseFunctions

def initialize
Expand All @@ -133,7 +130,6 @@ def block_length
end

class SHA384 < Base

extend BaseFunctions

def initialize
Expand All @@ -147,7 +143,6 @@ def block_length
end

class SHA512 < Base

extend BaseFunctions

def initialize
Expand All @@ -160,4 +155,10 @@ def block_length

end

def self.hexencode(message)
raise TypeError if message.nil?
raise TypeError if message.is_a? Fixnum

This comment has been minimized.

Copy link
@eregon

eregon May 19, 2015

Member

Could we use a helper such as StringValue or coerce_ from Rubinius here?

This comment has been minimized.

Copy link
@chrisseaton

chrisseaton May 19, 2015

Author Contributor

I'll try that - I wasn't sure if the Fixnum thing was a special case.

This comment has been minimized.

Copy link
@chrisseaton

chrisseaton May 19, 2015

Author Contributor

Done in d78025c

message.to_str.unpack('H*').first
end

end
5 changes: 0 additions & 5 deletions spec/truffle/tags/library/digest/hexencode_tags.txt

This file was deleted.

0 comments on commit 78953ad

Please sign in to comment.