-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncryptUtil.java
More file actions
executable file
·34 lines (28 loc) · 968 Bytes
/
Copy pathEncryptUtil.java
File metadata and controls
executable file
·34 lines (28 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package HPQC;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import com.ibm.misc.BASE64Decoder;
import com.ibm.misc.BASE64Encoder;
public class EncryptUtil {
public static final String DEFAULT_ENCODING="UTF-8";
static BASE64Encoder enc=new BASE64Encoder();
static BASE64Decoder dec=new BASE64Decoder();
public static String encrypt(String toEncrypt) {
try {
return enc.encode(toEncrypt.getBytes(DEFAULT_ENCODING));
} catch (UnsupportedEncodingException e) {
return null;
}
}
public static String decrypt(String toDecrypt){
try {
return new String(dec.decodeBuffer(toDecrypt), DEFAULT_ENCODING);
} catch (IOException e) {
return null;
}
}
public static void main(String args[]) {
String password = "";
System.out.println(encrypt(password));
}
}