ffi-libsodium 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sodium.rb +11 -0
- data/lib/sodium/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95e3d3e55b58d22b7d16193380dd64acf5b53795
|
4
|
+
data.tar.gz: 75cacb7cf5499370e9e87b591450312c831f3748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27dacc84385dff1c3c7759165a2e7ffd5fa9b440866088d3425318918aaff09ce6afd3433ce5ed481dfd798df7fa5a307b7833b738402b89d0c03bc8aa8d4960
|
7
|
+
data.tar.gz: e1877366d0aa2ec42624c55ff64e5bf10a3ec951245577658b72e3842ae46b511477d8e8e3ddce904bfe0b38090ed9c4111412befa78300d18dc1ebc3ac9edc6
|
data/lib/sodium.rb
CHANGED
@@ -71,4 +71,15 @@ module Sodium
|
|
71
71
|
raise LengthError, "bin_maxlen=#{bin_maxlen} is too short", caller
|
72
72
|
end
|
73
73
|
end
|
74
|
+
|
75
|
+
def hex2bin_in_place(hex, bin_maxlen, ignore = nil)
|
76
|
+
bin_len = FFI::MemoryPointer.new(:size_t)
|
77
|
+
if sodium_hex2bin(hex, bin_maxlen, hex, hex.bytesize, ignore, bin_len, nil) == 0
|
78
|
+
size = bin_len.size == 8 ? bin_len.read_uint64 : bin_len.read_uint32
|
79
|
+
hex.slice!(size..-1)
|
80
|
+
hex
|
81
|
+
else
|
82
|
+
raise LengthError, "bin_maxlen=#{bin_maxlen} is too short", caller
|
83
|
+
end
|
84
|
+
end
|
74
85
|
end
|
data/lib/sodium/version.rb
CHANGED