不明白这样做

时间:2016-11-08 07:54:58

标签: java encoding

public String encrypt(String line) throws UnsupportedEncodingException {

    String newLine = "";

    byte[] bytes = line.getBytes("UTF-8");
    for (byte c : bytes) {
        newLine += Integer.toHexString(c);
    }
    System.out.println(newLine);

    return newLine;
}

public String decrypt(String line) throws UnsupportedEncodingException {

    String newLine = "";

    byte[] bytes = line.getBytes("UTF-8");
    for (byte b : bytes) {
        char c = (char) b;
        newLine += c;

    }

    return newLine;
}

这是两种方法。不知道如何纠正这个。 这样可以使它正确吗?我希望在解密方法

中将返回的加密线转换为法线

0 个答案:

没有答案
相关问题