# File lib/quiz1/t/solutions/Jamis Buck/lib/cipher.rb, line 113
  def encrypt( message )
    reset

    chars = message.split(//).map { |c| c.upcase }. reject { |c| c !~ /[A-Z]/ }
    chars.concat ["X"] * ( 5 - chars.length % 5 ) if chars.length % 5 > 0
    chars.map! { |c| c[0] - 64 }
    key = generate_key( chars.length )
    code = chars.zip( key ).map { |c,k| ( c + k > 26 ? c + k - 26 : c + k ) }.map { |c| (c+64).chr }

    msg = ""
    (code.length/5).times do
      msg << " " if msg.length > 0
      5.times { msg << code.shift }
    end

    return msg
  end