vendor/gems/rubyzip-0.9.1/lib/quiz1/t/solutions/Thomas Leitner/solitaire.rb
# Encodes the given +msg+ using the internal deck
Encodes the given +msg+ using the internal deck
Encodes the given + msg + using the internal deck
def encode( msg )
    msg = msg.gsub(/[^A-Za-z]/, '').upcase
    msg += "X"*(5 - (msg.length % 5)) unless msg.length % 5 == 0
    msgNumbers = to_numbers( msg )
    cipherNumbers = to_numbers( generate_keystream( msg.length ) )
    resultNumbers = []
    msgNumbers.each_with_index do |item, index|
      temp = item + cipherNumbers[index]
      temp = temp - 26 if temp > 26
      resultNumbers << temp
    end
    return to_chars( resultNumbers )
  end
def encode ( msg ) msg = msg . gsub ( / [^A-Za-z] / , '' ) . upcase msg += "X" * ( 5 - ( msg . length % 5 ) ) unless msg . length % 5 == 0 msgNumbers = to_numbers ( msg ) cipherNumbers = to_numbers ( generate_keystream ( msg . length ) ) resultNumbers = [ ] msgNumbers . each_with_index do | item , index | temp = item + cipherNumbers [ index ] temp = temp - 26 if temp > 26 resultNumbers << temp end return to_chars ( resultNumbers ) end
Encodes the given +msg+ using the internal deck
Encodes the given + msg + using the internal deck
msg
<not_specific>