Java String Encrypt Encrypt(String str)

Here you can find the source of Encrypt(String str)

Description

Encrypt

License

Apache License

Declaration

public static String Encrypt(String str) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String Encrypt(String str) {
        return Str2Unicode(encryStr("IBMExtract", str));
    }/*from w  ww.  j  av a  2  s.com*/

    private static String Str2Unicode(String str) {
        String result = "";
        char[] chars = str.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            String hexa = Long.toHexString(chars[i]).toUpperCase();
            result = result
                    + new StringBuilder().append("0000").append(hexa)
                            .toString()
                            .substring(hexa.length(), hexa.length() + 4);
        }
        return result;
    }

    private static String encryStr(String encKey, String toEnc) {
        int t = 0;
        int encKeyI = 0;
        while (t < encKey.length()) {
            encKeyI += encKey.charAt(t);
            t++;
        }
        return encry(encKeyI, toEnc);
    }

    private static String encry(int encKey, String toEnc) {
        int t = 0;
        String tog = "";
        if (encKey > 0) {
            while (t < toEnc.length()) {
                int a = toEnc.charAt(t);
                int c = a ^ encKey;
                char d = (char) c;
                tog = tog + d;
                t++;
            }
        }
        return tog;
    }
}

Related

  1. encrypt(int original, int salt)
  2. encrypt(String data, String key)
  3. encrypt(String inStr)
  4. encrypt(String s)
  5. encrypt(String s)
  6. encrypt(String str)
  7. Encrypt(String str, String salt)
  8. encrypt(String string)
  9. encrypt(String string)