Skip to content

Instantly share code, notes, and snippets.

@patrickfav
Created April 24, 2019 18:14
Show Gist options
  • Save patrickfav/925a617862cdb6f246b7c334aeb81270 to your computer and use it in GitHub Desktop.
Save patrickfav/925a617862cdb6f246b7c334aeb81270 to your computer and use it in GitHub Desktop.
Id Mask 64-Bit Integer Example for Medium Article
byte[] key = Bytes.random(16).array();
long id = ...
IdMask<Long> idMask = IdMasks.forLongIds(Config.builder(key).build());
String maskedId = idMask.mask(id);
//example: NPSBolhMyabUBdTyanrbqT8
long originalId = idMask.unmask(maskedId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment