lib/ffi/hydrogen.rb in ffi-hydrogen-0.1.1 vs lib/ffi/hydrogen.rb in ffi-hydrogen-0.1.2

- old
+ new

@@ -8,11 +8,11 @@ # define hydro_secretbox_HEADERBYTES (20 + 16) KEYBYTES = 32 HEADERBYTES = 36 gem_base = ::File.join(::File.dirname(__FILE__), "..", "..") - ffi_lib "#{gem_base}/vendor/main.#{::FFI::Platform::LIBSUFFIX}" + ffi_lib "#{gem_base}/ext/ffi/hydrogen/main.#{::FFI::Platform::LIBSUFFIX}" # void hydro_secretbox_keygen(uint8_t key[hydro_secretbox_KEYBYTES]) attach_function :_hydro_secretbox_keygen, :hydro_secretbox_keygen, [:pointer], :void # int hydro_secretbox_encrypt(uint8_t *c, const void *m_, size_t mlen, uint64_t msg_id, @@ -50,11 +50,11 @@ create_key(key) do |key_ptr| create_context(context) do |context_ptr| create_string_and_buffer(text, max_len) do |text_ptr, buff_ptr| size = _encrypt_encode(buff_ptr, text_ptr, text_len, message_id, context_ptr, key_ptr) - result = buff_ptr.get_bytes(0, size) + result = buff_ptr.get_bytes(0, size) if size != 0 end end end result @@ -66,12 +66,14 @@ max_len = modp_b64_decode_len(text_len) create_key(key) do |key_ptr| create_context(context) do |context_ptr| create_string_and_buffer(text, max_len) do |text_ptr, buff_ptr| + # binding.pry + size = _decode_decrypt(buff_ptr, text_ptr, text_len, message_id, context_ptr, key_ptr) - result = buff_ptr.get_bytes(0, size) + result = buff_ptr.get_bytes(0, size) if size != 0 end end end result @@ -82,11 +84,11 @@ text_len = text.bytesize buff_len = modp_b64_encode_len(text_len) create_string_and_buffer(text, buff_len) do |text_ptr, buff_ptr| size = ::FFI::Hydrogen._modp_b64_encode(buff_ptr, text_ptr, text_len) - encoded = buff_ptr.get_bytes(0, size) + encoded = buff_ptr.get_bytes(0, size) if size != 0 end encoded end @@ -95,10 +97,10 @@ text_len = text.bytesize buff_len = modp_b64_decode_len(text_len) create_string_and_buffer(text, buff_len) do |text_ptr, buff_ptr| size = ::FFI::Hydrogen._modp_b64_decode(buff_ptr, text_ptr, text_len) - decoded = buff_ptr.get_bytes(0, size) + decoded = buff_ptr.get_bytes(0, size) if size != 0 end decoded end