Here you can find the source of encryption(String str, int k)
public static String encryption(String str, int k)
//package com.java2s; //License from project: Apache License public class Main { public static String encryption(String str, int k) { String string = ""; for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c >= 'a' && c <= 'z') { c += k % 26;/* www.j a v a 2 s .co m*/ if (c < 'a') { c += 26; } if (c > 'z') { c -= 26; } } else if (c >= 'A' && c <= 'Z') { c += k % 26; if (c < 'A') { c += 26; } if (c > 'Z') { c -= 26; } } string += c; } return string; } }