i don't understand this method haw it work !!!?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hamza
    New Member
    • Oct 2012
    • 1

    i don't understand this method haw it work !!!?

    Code:
    private char encryptChar(char c, int k) {
        	if (Character.isLetter(c))
        		return (char) ('A' + (c - 'A' + k) % 26);
        	else
        		return c;
        }
    Last edited by Rabbit; Oct 10 '12, 12:19 AM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It's basically a caeser cipher. Meaning that it shifts a character k number of characters forward. With k = 1, a becomes b, b becomes c, c becomes d, z becomes a, etc.

    Comment

    Working...