Ejemplo n.º 1
0
 public static String decryptWithKeyBase64(String data, String key) {
   try {
     byte[] originalData = Base64.decode(data.getBytes());
     byte[] valueByte = decrypt(originalData, Base64.decode(key.getBytes()));
     return new String(valueByte, ConfigureEncryptAndDecrypt.CHAR_ENCODING);
   } catch (UnsupportedEncodingException e) {
     throw new RuntimeException("decrypt fail!", e);
   }
 }
Ejemplo n.º 2
0
 public static String encryptToBase64(String data, String key) {
   try {
     byte[] valueByte =
         encrypt(
             data.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING),
             key.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING));
     return new String(Base64.encode(valueByte));
   } catch (UnsupportedEncodingException e) {
     throw new RuntimeException("encrypt fail!", e);
   }
 }
Ejemplo n.º 3
0
 public static String genarateRandomKeyWithBase64() {
   return new String(Base64.encode(genarateRandomKey()));
 }