Class: Win32::Certstore::Mixin::Crypto::CRYPT_HASH_BLOB

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/win32/certstore/mixin/crypto.rb

Instance Method Summary collapse

Constructor Details

#initialize(str = nil) ⇒ CRYPT_HASH_BLOB

Returns a new instance of CRYPT_HASH_BLOB.



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/win32/certstore/mixin/crypto.rb', line 142

def initialize(str = nil)
  super(nil)
  if str
    byte_arr = [str].pack("H*").unpack("C*") # Converting string to its byte array

    buffer = FFI::MemoryPointer.new(:char, byte_arr.size) # Create the pointer to the array
    buffer.put_array_of_char 0, byte_arr                  # Fill the memory location with data
    self[:pbData] = buffer
    self[:cbData] = byte_arr.size
  end
end