6 added shorter version
source | link

Python 2 - 188 / 182

This should obey the requirements faithfully:

import os
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
h=lambda n:eval('"%X"%(a.next()*4+a.next())+'*n+'"-"')
exec'print h(8)+h(4)+"4"+h(3)+"%X"%(8+a.next())+h(3)+h(12)[:-1];'*4

If python's UUID is acceptable for outputting a nicely-formatted uuid from a 32-digit hex string, then this version has 182 bytes:

import os,uuid
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
exec('s='+'"%X"%(a.next()*4+a.next())+'*30+'"";print uuid.UUID(s[3:15]+"4"+s[:3]+"%X"%(8+a.next())+s[15:]);')*4

a is a generator comprehension that gives 2 bits at a time from an initial source of 61 random bytes.

Thanks TheRare for tips

Python 2 - 188

This should obey the requirements faithfully:

import os
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
h=lambda n:eval('"%X"%(a.next()*4+a.next())+'*n+'"-"')
exec'print h(8)+h(4)+"4"+h(3)+"%X"%(8+a.next())+h(3)+h(12)[:-1];'*4

a is a generator comprehension that gives 2 bits at a time from an initial source of 61 random bytes.

Thanks TheRare for tips

Python 2 - 188 / 182

This should obey the requirements faithfully:

import os
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
h=lambda n:eval('"%X"%(a.next()*4+a.next())+'*n+'"-"')
exec'print h(8)+h(4)+"4"+h(3)+"%X"%(8+a.next())+h(3)+h(12)[:-1];'*4

If python's UUID is acceptable for outputting a nicely-formatted uuid from a 32-digit hex string, then this version has 182 bytes:

import os,uuid
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
exec('s='+'"%X"%(a.next()*4+a.next())+'*30+'"";print uuid.UUID(s[3:15]+"4"+s[:3]+"%X"%(8+a.next())+s[15:]);')*4

a is a generator comprehension that gives 2 bits at a time from an initial source of 61 random bytes.

Thanks TheRare for tips

5 shortened
source | link

Python 2 - 197188

My python-fu is not that strong, I expect this can be improved quite a bit. But at least itThis should obey the requirements faithfully:

import os
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
h=lambda n:''.joineval("%X"%'"%X"%(a.next()*4+a.next())for _ in[0]*n)+'+'*n+'"-'"')
exec'print h(8)+h(4)+"4"+h(3)+"%X"%(8+a.next())+h(3)+h(12)[:-1];'*4

a is now a generator comprehension that gives 2 random bits at a time from an initial source of 61 random bytes.

Thanks TheRare for tips

Python 2 - 197

My python-fu is not that strong, I expect this can be improved quite a bit. But at least it should obey the requirements faithfully:

import os
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
h=lambda n:''.join("%X"%(a.next()*4+a.next())for _ in[0]*n)+'-'
exec'print h(8)+h(4)+"4"+h(3)+"%X"%(8+a.next())+h(3)+h(12)[:-1];'*4

a is now a generator comprehension that gives 2 random bits at a time

Thanks TheRare for tips

Python 2 - 188

This should obey the requirements faithfully:

import os
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
h=lambda n:eval('"%X"%(a.next()*4+a.next())+'*n+'"-"')
exec'print h(8)+h(4)+"4"+h(3)+"%X"%(8+a.next())+h(3)+h(12)[:-1];'*4

a is a generator comprehension that gives 2 bits at a time from an initial source of 61 random bytes.

Thanks TheRare for tips

4 shortened
source | link

Python 2 - 228197

My python-fu is not that strong, I expect this can be improved quite a bit. But at least it should obey the requirements faithfully:

import os
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
s=""
defh=lambda h(n,c='-'):
 global s
 for i in range''.join(n):s+="%X"%"%X"%(a.next()*4+a.next())
 for s+=c_ in[0]*n)+'-'
exec'hexec'print h(8);h+h(4);s+="4";h+"4"+h(3);s+="%X"%+"%X"%(8+a.next());h+h(3);h+h(12,"\\n");'*4
print s[:-1];'*4

a is now a generator comprehension that gives 2 random bits at a time

Thanks TheRare for tips

Python 2 - 228

My python-fu is not that strong, I expect this can be improved quite a bit. But at least it should obey the requirements faithfully:

import os
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
s=""
def h(n,c='-'):
 global s
 for i in range(n):s+="%X"%(a.next()*4+a.next())
  s+=c
exec'h(8);h(4);s+="4";h(3);s+="%X"%(8+a.next());h(3);h(12,"\\n");'*4
print s

a is now a generator comprehension that gives 2 random bits at a time

Thanks TheRare for tips

Python 2 - 197

My python-fu is not that strong, I expect this can be improved quite a bit. But at least it should obey the requirements faithfully:

import os
a=(ord(x)>>i&3for i in(0,2,4,6)for x in os.urandom(61))
h=lambda n:''.join("%X"%(a.next()*4+a.next())for _ in[0]*n)+'-'
exec'print h(8)+h(4)+"4"+h(3)+"%X"%(8+a.next())+h(3)+h(12)[:-1];'*4

a is now a generator comprehension that gives 2 random bits at a time

Thanks TheRare for tips

3 shortened
source | link
2 shortened
source | link
1
source | link