List of usage examples for java.nio ByteBuffer putLong
public abstract ByteBuffer putLong(long value);
From source file:Main.java
/** * Generates a Base64 version of UUID/* w w w .ja va 2s . c o m*/ * @return a string in Base64 URL-safe format without padding at the end and no wrapping */ public static String randomUuidBase64() { UUID uuid = UUID.randomUUID(); ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return encodeUrlSafe64(bb.array()); }
From source file:Main.java
private static byte[] longToBytes(long value) { ByteBuffer buffer = ByteBuffer.allocate(BYTE_BUFFER_CAPACITY); buffer.putLong(value); return buffer.array(); }
From source file:org.zht.framework.uuid.Base64UuidGenerator.java
private static String base64Uuid(UUID uuid) { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return Base64.encodeBase64URLSafeString(bb.array()); }
From source file:com.images3.data.impl.ShortUUID.java
private static byte[] toByteArray(UUID uuid) { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return bb.array(); }
From source file:Main.java
public static byte[] createDigest(String passcode, long t1, double q1) throws IOException, NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(passcode.getBytes());/*from ww w .jav a 2 s . co m*/ ByteBuffer bb = ByteBuffer.allocate(16); //8 bytes for long and double each bb.putLong(t1); bb.putDouble(q1); md.update(bb); return md.digest(); }
From source file:com.hengyi.japp.tools.UuidUtils.java
protected static String base64Uuid(UUID uuid) { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return Base64.encodeBase64URLSafeString(bb.array()); }
From source file:com.hengyi.japp.tools.UuidUtils.java
protected static String base58Uuid(UUID uuid) { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return Base58.encode(bb.array()); }
From source file:crocserver.app.CrocSecurity.java
private static byte[] toByteArray(long value) { ByteBuffer buffer = ByteBuffer.allocate(8); buffer.putLong(value); return buffer.array(); }
From source file:com.microsoft.applicationinsights.extensibility.initializer.SequencePropertyInitializer.java
private static String uuidToBase64() { Base64 base64 = new Base64(); UUID uuid = UUID.randomUUID(); ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return base64.encodeBase64URLSafeString(bb.array()); }
From source file:Main.java
public static byte[] uuidToBytes(String uuidStr) { UUID uuid = stringToUuid(uuidStr); ByteBuffer bb = ByteBuffer.allocate(16); bb.order(ByteOrder.LITTLE_ENDIAN); bb.putLong(uuid.getLeastSignificantBits()); bb.putLong(uuid.getMostSignificantBits()); return bb.array(); }