module PkernelJce module IoUtils def IoUtils.file_to_memory_byte_array(path) if path.nil? or path.empty? raise PkernelJce::Error, "Given path '#{path}' to load to memory is nil or empty" else f = java.io.File.new(path) b = Java::byte[f.length].new dis = java.io.DataInputStream.new(java.io.FileInputStream.new(f)) dis.readFully(b) dis.close b end end # end file_to_memory_byte_array # def IoUtils.ensure_java_bytes(bin) if not bin.java_kind_of?(Java::byte[]) bin.to_java_bytes elsif bin.is_a?(String) bin = bin.to_java.getBytes else bin end end # end ensure_java_bytes # def IoUtils.to_hex(bin) String.from_java_bytes(org.bouncycastle.util.encoders.Hex.encode(bin)) end def IoUtils.from_hex(str) org.bouncycastle.util.encoders.Hex.decode(str) end end # end IoUtils # end # end PkernelJce #