Skip to content

Instantly share code, notes, and snippets.

@grimmdev
Last active April 15, 2017 09:21
Show Gist options
  • Save grimmdev/cc6672ad34a8391d544b9b60d6cb99df to your computer and use it in GitHub Desktop.
Save grimmdev/cc6672ad34a8391d544b9b60d6cb99df to your computer and use it in GitHub Desktop.
32 bits of goodness.
using System;
public class ShortGUID
{
private static Guid tmpGuid;
public static string NewGuid()
{
tmpGuid = Guid.NewGuid ();
return Convert.ToBase64String(tmpGuid.ToByteArray());
}
}
<?php
function generate_uuid() {
return sprintf( '%04x%04x%04x%04x%04x%04x%04x%04x',
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
mt_rand( 0, 0xffff ),
mt_rand( 0, 0x0fff ) | 0x4000,
mt_rand( 0, 0x3fff ) | 0x8000,
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment