module Ansible::Vault::BinASCII

A Ruby implementation of part of Python’s binascii module

Public Class Methods

hexlify(bin_data) click to toggle source

Convert the supplied binary string to the hex representation

@param [String] bin_data The binary data to encode @return [String] The hex encoded binary data.

# File lib/ansible/vault/bin_ascii.rb, line 9
def self.hexlify(bin_data)
  bin_data.unpack('H*').first
end
unhexlify(hex_data) click to toggle source

Convert the hexadecimal represenation of data back to binary

@param [String] hex_data The hex data to convert back to binary @return [String] The binary representation of the supplied hex data

# File lib/ansible/vault/bin_ascii.rb, line 17
def self.unhexlify(hex_data)
  [hex_data].pack('H*')
end