Guest User

Untitled

a guest
Jun 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. Пример кода должен выглядеть так
  2. public static String test(String data) throws NoSuchAlgorithmException {
  3. MessageDigest md = MessageDigest.getInstance("SHA-256");
  4. md.update(data.getBytes());
  5. return bytesToHex(md.digest());
  6. }
  7. public static String bytesToHex(byte[] bytes) {
  8. StringBuffer result = new StringBuffer();
  9. for (byte byt : bytes) result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));
  10. return result.toString();
  11. }
  12. }
  13.  
  14. String str = "u0074u0065u0073u0074";
  15. str = new String(str.getBytes("utf-8"), "utf-8");
  16. System.out.println(str); //test
Add Comment
Please, Sign In to add comment