Вот код кодировки base64:
require 'Base64'
file = File.open("temp.txt", "r")
byte_array = []
file.seek(6) # go to 7th byte
byte_array << file.getbyte
file.seek(file.size - 1)
byte_array << file.getbyte
Base64.encode64(byte_array.pack('c*'))
РЕДАКТИРОВАТЬ Если вы не хотите явно кодировать base64, вы также можете напечатать значения байтов, например:
puts byte_array * " "