List of usage examples for java.lang String hashCode
public int hashCode()
From source file:Main.java
public static String hashkeyForDisk(String url) { try {//from www.ja v a2 s . c o m final MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(url.getBytes()); return bytesToHexString(digest.digest()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return String.valueOf(url.hashCode()); } }
From source file:de.unidue.inf.is.ezdl.dlservices.repository.store.repositories.DBRepository.java
private static String databaseIdForOid(String oid) { if (oid.length() >= OID_LENGTH_FOR_HASHCODE) { return String.valueOf(oid.hashCode()); } else {//from w w w. ja v a 2s. c o m return oid; } }
From source file:Main.java
public static String md5(String str) { String cacheKey;/*from w w w.ja va 2 s . co m*/ try { final MessageDigest mDigest = MessageDigest.getInstance("MD5"); mDigest.update(str.getBytes()); cacheKey = bytesToHexString(mDigest.digest()); } catch (NoSuchAlgorithmException e) { cacheKey = String.valueOf(str.hashCode()); } return cacheKey; }
From source file:Main.java
public static String keyToHashKey(String key) { String cacheKey;//from w ww .java 2 s.c o m try { final MessageDigest mDigest = MessageDigest.getInstance("MD5"); mDigest.update(key.getBytes()); cacheKey = bytesToHexString(mDigest.digest()); } catch (NoSuchAlgorithmException e) { cacheKey = String.valueOf(key.hashCode()); } return cacheKey; }
From source file:Main.java
/** * A hashing method that changes a string (like a URL) into a hash suitable * for using as a disk filename./*from w ww . j ava 2 s. co m*/ */ public static String hashKeyForUrl(String key) { String cacheKey; try { final MessageDigest mDigest = MessageDigest.getInstance("MD5"); mDigest.update(key.getBytes()); cacheKey = bytesToHexString(mDigest.digest()); } catch (NoSuchAlgorithmException e) { cacheKey = String.valueOf(key.hashCode()); } return cacheKey; }
From source file:Main.java
public static String hashKeyForDisk(String key) { String cacheKey;/*from w w w . jav a 2s . c o m*/ try { final MessageDigest mDigest = MessageDigest.getInstance("MD5"); mDigest.update(key.getBytes()); cacheKey = bytesToHexString(mDigest.digest()); } catch (NoSuchAlgorithmException e) { cacheKey = String.valueOf(key.hashCode()); } return cacheKey; }
From source file:Main.java
public static String hashKey(String key) { String cacheKey;/*from w ww.j a v a 2 s. c o m*/ try { final MessageDigest mDigest = MessageDigest.getInstance("MD5"); mDigest.update(key.getBytes()); cacheKey = bytesToHexString(mDigest.digest()); } catch (NoSuchAlgorithmException e) { cacheKey = String.valueOf(key.hashCode()); } return cacheKey; }
From source file:Main.java
public static String getDeviceKey(Context ctx) { final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); final String tmDevice, tmSerial, androidId; tmDevice = "" + tm.getDeviceId(); tmSerial = "" + tm.getSimSerialNumber(); androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); return deviceUuid.toString(); }
From source file:edu.umd.cs.marmoset.utilities.MarmosetUtilities.java
public static int hashString(String s) { return s == null ? 0 : s.hashCode(); }
From source file:com.google.cloud.genomics.dockerflow.util.FileUtils.java
/** * A local path or file name on local disk. * * @param gcsPath GCS path or, if testing locally, a path on the local machine */// w w w . ja v a 2 s. co m public static String localPath(String gcsPath) { if (gcsPath == null) { return null; } String localPath = gcsPath; // If multiple files, store in the root of the mounted drive if (gcsPath.indexOf("*") > 0 || gcsPath.split("\\s+").length > 1) { localPath = ""; // Otherwise store by the input file name, prefixed with a hashcode // for the parent path, so files in the same directory preserve name relations. // Eg, file.tar and file.tar.gz. } else { String dir = gcsPath.contains("/") ? gcsPath.substring(0, gcsPath.lastIndexOf("/")) : gcsPath; localPath = String.valueOf(dir.hashCode()).replace("-", "") + "-" + gcsPath.substring(gcsPath.lastIndexOf("/") + 1); } return localPath; }