waterjuice

PersonalGuid.py

Aug 28th, 2019
204
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python3
  2. #-----------------------------------------------------------------------------------------------------------------------
  3. #   PersonalGuid
  4. #
  5. #   Creates a "Personal GUID" based on the method specified in http://waterjuice.org/2013/06/personal-guids/
  6. #
  7. #   This is free and unencumbered software released into the public domain - August 2019 waterjuice.org
  8. #-----------------------------------------------------------------------------------------------------------------------
  9.  
  10. import sys
  11. import uuid
  12.  
  13. if 7 != len(sys.argv):
  14.     print(
  15.         "PersonalGuid - Version 1.0.1 (August 2019)\n" +
  16.         "Syntax\n" +
  17.         "   PersonalGuid <Surname> <GivenNames> <Sex> <CountryOfBirth> <PlaceOfBirth> <DateOfBirth>\n" +
  18.         "   Sex must be 'F', 'M', or 'X'\n" +
  19.         "   DateOfBirth must be of format YYYYMMDD" )
  20.     exit( 1 )
  21.  
  22. surname         = sys.argv[1].upper()
  23. givenNames      = sys.argv[2].upper()
  24. sex             = sys.argv[3].upper()
  25. countryOfBirth  = sys.argv[4].upper()
  26. placeOfBirth    = sys.argv[5].upper()
  27. dateOfBirthStr  = sys.argv[6].upper()
  28.  
  29. # Get gender
  30. if 'M' != sex and 'F' != sex and 'X' != sex:
  31.     print( "Invalid sex specified. Must be 'M', 'F', or 'X'" )
  32.     exit( 1 )
  33.  
  34. # Get date of birth
  35. if len(dateOfBirthStr) != 8 or not dateOfBirthStr.isdigit():
  36.     print( "Date str must be of format YYYYMMDD" )
  37.     exit( 1 )
  38.  
  39. # Verify other parameters
  40. if(     "" == surname
  41.     or  "" == givenNames
  42.     or  "" == countryOfBirth
  43.     or  "" == placeOfBirth ):
  44.     print( "Incorrect syntax" )
  45.     exit( 1 )
  46.  
  47. # Assemble id string
  48. idString = "%s;%s;%s;%s;%s;%s" % ( surname, givenNames, sex, countryOfBirth, placeOfBirth, dateOfBirthStr )
  49.  
  50. print( "ID: %s" % idString );
  51.  
  52. namespaceGuid = uuid.UUID( '{5b390b3f-9a62-508a-b235-6e6e8d270720}' )
  53.  
  54. # Create Type 5 GUID
  55. guid = uuid.uuid5( namespaceGuid, idString )
  56. print( '{%s}' % str(guid) )
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×