Exemplo n.º 1
0
  public static String encrypt(String str) {

    init();
    try {
      byte[] utf8 = str.getBytes("UTF8");
      byte[] enc = ecipher.doFinal(utf8);
      enc = BASE64EncoderStream.encode(enc);

      return new String(enc);

    } catch (UnsupportedEncodingException | IllegalBlockSizeException | BadPaddingException e) {
      System.out.println("Encrypt exception:" + e.getMessage());
    }
    return null;
  }