Android String Encrypt encrypt(String str)

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

Description

encrypt

Declaration

public static String encrypt(String str) 

Method Source Code

//package com.java2s;
import java.io.UnsupportedEncodingException;

public class Main {

    public static String encrypt(String str) {
        String key = "a12348a9gde";
        StringBuilder sb = new StringBuilder();
        try {//from   ww w.ja  va2 s .  c om
            byte[] data = str.getBytes("UTF-8");
            byte[] keyData = key.getBytes("UTF-8");
            for (int i = 0; i < data.length; i++) {
                String s = String.format("%02X", data[i] & 0xFF
                        ^ keyData[i % keyData.length] & 0xFF);
                sb.append(s);
            }
        } catch (UnsupportedEncodingException e) {

        } catch (Exception e) {

        }
        return sb.toString();
    }
}

Related

  1. encrypt(String keyStr, String plainText)
  2. encrypt(String seed, String cleartext)