module KRB5::Mixin::Packer
Public Instance Methods
pack_bytes(data)
click to toggle source
# File lib/krb5/mixin/packer.rb, line 19 def pack_bytes(data) @bytes ||= [] if data.is_a?(Array) @bytes += data elsif data.is_a?(String) @bytes << data end end
pack_data(data)
click to toggle source
Generic method to pack Kerberos data
data ::=
length (16 bits) value (length bytes)
See: web.mit.edu/kerberos/krb5-1.16/doc/formats/keytab_file_format.html
@return [String]
# File lib/krb5/mixin/packer.rb, line 14 def pack_data(data) pack_int16(data.length) pack_bytes(data) end
pack_int16(data)
click to toggle source
# File lib/krb5/mixin/packer.rb, line 35 def pack_int16(data) @bytes ||= [] @bytes << [data].pack('s>') end
pack_int32(data)
click to toggle source
# File lib/krb5/mixin/packer.rb, line 41 def pack_int32(data) @bytes ||= [] @bytes << [data].pack('l>') end
pack_int8(data)
click to toggle source
# File lib/krb5/mixin/packer.rb, line 29 def pack_int8(data) @bytes ||= [] @bytes << [data].pack('c') end