Skip to content

Instantly share code, notes, and snippets.

@Newlifer
Last active June 15, 2017 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Newlifer/5722460ab77cb09a7623b76093f51085 to your computer and use it in GitHub Desktop.
Save Newlifer/5722460ab77cb09a7623b76093f51085 to your computer and use it in GitHub Desktop.
id_generator.d
import std.stdio;
import std.uuid;
import std.digest.murmurhash;
import std.format;
import std.bitmanip;
import std.system;
string next_id() {
auto uuid = randomUUID();
MurmurHash3!32 hasher;
hasher.put(uuid.data);
hasher.finalize();
auto ret = peek!(uint, Endian.littleEndian)(hasher.getBytes());
return "%x".format(ret);
}
int main() {
next_id.writeln;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment