Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Пример кода должен выглядеть так
- public static String test(String data) throws NoSuchAlgorithmException {
- MessageDigest md = MessageDigest.getInstance("SHA-256");
- md.update(data.getBytes());
- return bytesToHex(md.digest());
- }
- public static String bytesToHex(byte[] bytes) {
- StringBuffer result = new StringBuffer();
- for (byte byt : bytes) result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));
- return result.toString();
- }
- }
- String str = "u0074u0065u0073u0074";
- str = new String(str.getBytes("utf-8"), "utf-8");
- System.out.println(str); //test
Add Comment
Please, Sign In to add comment