Class: Confium::Digest
- Inherits:
-
Digest::Class
- Object
- Digest::Class
- Confium::Digest
- Defined in:
- lib/confium/digest.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ptr ⇒ Object
readonly
Returns the value of attribute ptr.
Class Method Summary collapse
Instance Method Summary collapse
- #block_length ⇒ Object
- #digest_length ⇒ Object
- #finish ⇒ Object
-
#initialize(cfm, name) ⇒ Digest
constructor
A new instance of Digest.
- #initialize_copy(source) ⇒ Object
- #reset ⇒ Object
- #update(data) ⇒ Object (also: #<<)
Constructor Details
#initialize(cfm, name) ⇒ Digest
Returns a new instance of Digest.
9 10 11 12 13 14 15 16 |
# File 'lib/confium/digest.rb', line 9 def initialize(cfm, name) @name = name pptr = FFI::MemoryPointer.new(:pointer) Confium.call_ffi(:cfm_hash_create, cfm.ptr, pptr, name, nil, nil, nil) ptr = pptr.read_pointer raise if ptr.null? @ptr = FFI::AutoPointer.new(ptr, self.class.method(:destroy)) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/confium/digest.rb', line 6 def name @name end |
#ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
7 8 9 |
# File 'lib/confium/digest.rb', line 7 def ptr @ptr end |
Class Method Details
Instance Method Details
#block_length ⇒ Object
30 31 32 33 34 |
# File 'lib/confium/digest.rb', line 30 def block_length plength = FFI::MemoryPointer.new(:uint32) Confium.call_ffi(:cfm_hash_block_size, @ptr, plength) plength.read(:uint32) end |
#digest_length ⇒ Object
36 37 38 39 40 |
# File 'lib/confium/digest.rb', line 36 def digest_length plength = FFI::MemoryPointer.new(:uint32) Confium.call_ffi(:cfm_hash_output_size, @ptr, plength) plength.read(:uint32) end |
#finish ⇒ Object
52 53 54 55 56 |
# File 'lib/confium/digest.rb', line 52 def finish buf = FFI::MemoryPointer.new(:uint8, digest_length) Confium.call_ffi(:cfm_hash_finalize, @ptr, buf, buf.size) buf.read_bytes(buf.size) end |
#initialize_copy(source) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/confium/digest.rb', line 18 def initialize_copy(source) @name = source.name pptr = FFI::MemoryPointer.new(:pointer) Confium.call_ffi(:cfm_hash_clone, source.ptr, pptr) ptr = pptr.read_pointer @ptr = FFI::AutoPointer.new(ptr, self.class.method(:destroy)) end |