Last active
October 14, 2019 12:28
-
-
Save jen20/781ced3a722481c9f223 to your computer and use it in GitHub Desktop.
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
var order = [...]int{3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15} | |
func wtfToUUID(netEncoded []byte) uuid.UUID { | |
uuidBytes := make([]byte, 16) | |
for i := 0; i < len(order); i++ { | |
uuidBytes[i] = netEncoded[order[i]] | |
} | |
return uuidBytes | |
} | |
//using the UUID type from "code.google.com/p/go-uuid/uuid" |
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
private static final int[] mostOrder = new int[]{3,2,1,0,5,4,7,6}; | |
private static UUID uuidFromWtf(byte[] dotNetEncodedGuid) { | |
long most = 0; | |
long least = 0; | |
for (int i : mostOrder) { | |
most = (most << 8) | (dotNetEncodedGuid[i] & 0xFF); | |
} | |
for (int i = 8; i < 16; i++) { | |
least = (least << 8) | (dotNetEncodedGuid[i] & 0xFF); | |
} | |
return new UUID(most, least); | |
} |
Sorry only just saw this - it is almost certainly required outside of the CLR and perhaps the windows API.
it is.
maybe node does the same? :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
How can I tell if this is necessary for https://github.com/bmavity/ges-client ?