Last active
June 15, 2017 13:52
-
-
Save Newlifer/5722460ab77cb09a7623b76093f51085 to your computer and use it in GitHub Desktop.
id_generator.d
This file contains 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
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