This loop ciphered the message . Spaces , special characters and numbers remain same .
for ( int i = 0 ; i < msg . length ( ) ; i ++ ) { if ( msg . charAt ( i ) >= ' a ' && msg . charAt ( i ) <= ' z ' ) { int pos = msg . charAt ( i ) - 97 ; cipher += encoded . charAt ( pos ) ; } else if ( msg . charAt ( i ) >= ' A ' && msg . charAt ( i ) <= ' Z ' ) { int pos = msg . charAt ( i ) - 65 ; cipher += encoded . charAt ( pos ) ; } else { cipher += msg . charAt ( i ) ; } } return cipher ; }