class Cryptopunks::Image::Composite
Constants
- PUNK_HASH
- PUNK_HEIGHT
- PUNK_WIDTH
Public Class Methods
new( *args, width: PUNK_WIDTH, height: PUNK_HEIGHT )
click to toggle source
Calls superclass method
# File lib/cryptopunks/composite.rb, line 31 def initialize( *args, width: PUNK_WIDTH, height: PUNK_HEIGHT ) super end
read( path='./punks.png' )
click to toggle source
# File lib/cryptopunks/composite.rb, line 12 def self.read( path='./punks.png' ) data = File.open( path, 'rb' ) { |f| f.read } hexdigest = sha256( data ) ## check sha256 checksum if hexdigest == PUNK_HASH puts " >#{hexdigest}< SHA256 hash matching" puts " ✓ True Official Genuine CryptoPunks™ verified" else puts " ✓ True Official Genuine Yes, You Can! Punks Not Dead™ verified" end img = ChunkyPNG::Image.from_blob( data ) new( img ) end
sha256( data )
click to toggle source
# File lib/cryptopunks/composite.rb, line 7 def self.sha256( data ) ## todo/check: or just use Digest::SHA256.hexdigest - why? why not? Digest::SHA256.digest( data ).unpack( 'H*' )[0] end