Created
September 4, 2014 12:59
-
-
Save berezovskyi/2c4d2a07fa2f35e5e04c to your computer and use it in GitHub Desktop.
convert a uuid to biginteger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private BigInteger getBigIntegerFromUuid(UUID randomUUID) { | |
ByteBuffer bb = ByteBuffer.wrap(new byte[16]); | |
bb.putLong(randomUUID.getMostSignificantBits()); | |
bb.putLong(randomUUID.getLeastSignificantBits()); | |
return new BigInteger(bb.array()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another approach using unsigned longs can be found here:
https://gist.github.com/drmalex07/9008c611ffde6cb2ef3a2db8668bc251