파이썬 uuid to b64uuid(), b64uuid to uuid()

1 개요[ | ]

파이썬 uuid_to_b64uuid(), b64uuid_to_uuid()
Python
Copy
import uuid
 
def uuid_to_b64uuid( u ):
	return uuid.UUID(u).bytes.encode('base64').rstrip('=\n').replace('+','-').replace('/','_')
 
def b64uuid_to_uuid( b64uuid ):
	return uuid.UUID(bytes=(b64uuid.replace('-','+').replace('_','/')+'==').decode('base64'))
 
print( uuid_to_b64uuid( '71c8851a-9a55-11e4-8e91-7831c1cda656' ) )
print( uuid_to_b64uuid( '11a38b9a-b3da-360f-9353-a5a725514269' ) )
print( uuid_to_b64uuid( '6c18d72a-1b7e-4afa-9bc1-1b1f5d34d7ce' ) )
print( uuid_to_b64uuid( 'c4a760a8-dbcf-5254-a0d9-6a4474bd1b62' ) )
print( uuid_to_b64uuid( '6dff26e7-c476-4483-8c2c-efe3c207a517' ) )
# cciFGppVEeSOkXgxwc2mVg
# EaOLmrPaNg-TU6WnJVFCaQ
# bBjXKht-SvqbwRsfXTTXzg
# xKdgqNvPUlSg2WpEdL0bYg
# bf8m58R2RIOMLO_jwgelFw

print( b64uuid_to_uuid( 'cciFGppVEeSOkXgxwc2mVg' ) )
print( b64uuid_to_uuid( 'EaOLmrPaNg-TU6WnJVFCaQ' ) )
print( b64uuid_to_uuid( 'bBjXKht-SvqbwRsfXTTXzg' ) )
print( b64uuid_to_uuid( 'xKdgqNvPUlSg2WpEdL0bYg' ) )
print( b64uuid_to_uuid( 'bf8m58R2RIOMLO_jwgelFw' ) )
# 71c8851a-9a55-11e4-8e91-7831c1cda656
# 11a38b9a-b3da-360f-9353-a5a725514269
# 6c18d72a-1b7e-4afa-9bc1-1b1f5d34d7ce
# c4a760a8-dbcf-5254-a0d9-6a4474bd1b62
# 6dff26e7-c476-4483-8c2c-efe3c207a517

2 같이 보기[ | ]