Java String Encrypt encryption(String str, int k)

Here you can find the source of encryption(String str, int k)

Description

encryption

License

Apache License

Declaration

public static String encryption(String str, int k) 

Method Source Code

//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;
    }
}

Related

  1. encryptBytes(final byte[] b, final int i)
  2. encryptChar(String caracter, int variable, int indice)
  3. EncryptDecrypt(String value)
  4. encryptEmailId(String emailId)
  5. encryptIfNotEncrypted(String s)
  6. encryptPlayerChat(byte[] is, int i_25_, int i_26_, int i_27_, byte[] is_28_)
  7. encryptPwd(String src)
  8. encryptStrBuff(byte[] resultBytes)
  9. encryptString(final String cadena)