-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathHash.java
More file actions
27 lines (23 loc) · 863 Bytes
/
Hash.java
File metadata and controls
27 lines (23 loc) · 863 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
package com.galtashma.parsedashboard;
import android.util.Log;
import java.security.MessageDigest;
public class Hash {
private static String salt = "1m4bqk";
public static String sha1(String value) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
messageDigest.update((value + salt).getBytes("UTF-8"));
byte[] bytes = messageDigest.digest();
StringBuilder buffer = new StringBuilder();
for (byte b : bytes) {
buffer.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
}
String result = buffer.toString();
Log.d(Const.TAG, "Hash result " + result);
return result;
} catch (Exception ignored) {
ignored.printStackTrace();
return null;
}
}
}