mguid [OPTION ...]
-h|--help|help
: Display this help information-v|--version|version
: Display the mguid version-V|--validate|validate
: Run validation testsversion=INT
: Set the magic trick version (default 0).magic=INT
: Set the magic number (default random 60 bit integer).trick=INT[,MAGIC[,VERSION]]
: Generate the check code using the magic numberand the magic trick version.
random[=MAGIC]
: Generate a magic random GUIDcheck=[GUID[,MAGIC]]
: Check whether a GUID is magicsame=[GUID,GUID[,MAGIC]]
: Check whether two GUIDs are generate with the samemagic.
random
option generates a Version 4 GUID using a random magic
number. If you know the magic number you can verify that a GUID was generated
with the magic number by using the check
option. If you have two GUIDs, you
can verify that they were generated using the same magic number using the
same
option.
If you do not specify the magic number, a random magic number is generated the
first time you use the random()
function. You can set the magic number using
the MAGIC
module constant, e.g., MAGIC=gen()
, MAGIC=123456
.
VERSION=0
only 60 bits are available for
generating unique GUIDs, meaning that there are only 1,152,921,504,606,846,976
possible magical GUIDs instead of the normal
5,316,911,983,139,663,491,615,228,241,121,378,304 possible muggle Version 4
GUIDs.
$ mguid random=123 f2ac57d8-e3e5-45d4-bf2a-c57d8e3e55afCheck whether the GUID was generated using the magic number 123.
$ mguid check=f2ac57d8-e3e5-45d4-bf2a-c57d8e3e55af,123 && echo ok || echo fail okCheck whether the GUID was generated using the magic number 456.
$ mguid check=f2ac57d8-e3e5-45d4-bf2a-c57d8e3e55af,456 && echo ok || echo fail failGenerates another GUID using the magic number 123.
$ mguid random=123 2f210452-75be-4d3b-a2f2-1045275bed40Checks whether the two GUIDs were generated using the same magic number.
$ mguid same=f2ac57d8-e3e5-45d4-bf2a-c57d8e3e55af,2f210452-75be-4d3b-a2f2-1 045275bed40 && echo ok || echo fail okGenerate another GUID using the magic number 456.
$ mguid random=456 0a335b25-d565-40fd-80a3-35b25d565135Check whether the new GUID was generared using the same magic number as the old GUID
$ mguid same=f2ac57d8-e3e5-45d4-bf2a-c57d8e3e55af,0a335b25-d565-40fd-80a3-3 5b25d565135 && echo ok || echo fail fail
>>> import mguid as mgGenerate a GUID.
>>> mg.random() 0c7d4f21-b322-41183-8086-479cd4100f63eCheck a GUID.
>>> mg.check(mg.random()) TrueCheck whether two GUIDs are generated using the same magic number.
>>> mg.same(mg.random(magic=123),mg.random(magic=123)) TrueCheck whether two GUIDs are generated using the same magic number.
>>> mg.same(mg.random(magic=123),mg.random(magic=456)) False
check(a:str, magic:int) → bool
a (str)
: a GUID to testmagic (int)
: the magic number to use in the test (default mguid.MAGIC)bool
: True if a was generated using magic, otherwise Falsegen() → int
bits (int)
: the number of bits to generate (default 61)int
: a N-bit random numbermain([list[str] | None]) → int
argv (list[str])
: argument listint
: exit coderandom(magic:int) → int
magic (int)
: the magic number to use (default mguid.MAGIC)int
: a magic GUIDsame(a:str, b:str) → bool
a (str)
: the first magic GUIDb (str)
: the second magic GUIDbool
: True if a and b were generated using the same magic numbertrick(a:int, magic:int, version:int) → int
a (int)
: the number to run the magic trick onmagic (int)
: the magic number to useversion (int)
: the version of the magic trick to use (default mguid.VERSION)int
: the result of the magic trickvalidate() → None
E_ERROR = 1
E_EXCEPTION = 2
E_OK = 0
MAGIC = None
VERSION = 0
: | mguid | |
: | 0.0.0a1 | |
: | GUIDs that are verifiably generated with magic number | |
: | David P. Chassin | |
: | David P. Chassin | |
: | >= 3.10 | |
: | None | |
: | guid magic | |
: | MIT License | |
: | Development Status :: 3 - Alpha Intended Audience :: Developers License :: OSI Approved :: MIT License Programming Language :: Python :: 3 :: Only Topic :: Software Development :: Libraries | |
: | Homepage = https://github.com/eudoxys/mguid Documentation = https://mguid.gitub.io/ Repository = https://github.com/eudoxys/mguid.git Issues = https://github.com/eudoxys/mguid/issues | |
: | mguid → main() |