pydicom.uid.generate_uid¶
- pydicom.uid.generate_uid(prefix='1.2.826.0.1.3680043.8.498.', entropy_srcs=None)¶
Return a 64 character UID which starts with prefix.
Changed in version 1.3: When prefix is
None
a conformant UUID suffix of up to 39 characters will be used instead of a hashed value.- Parameters
prefix (str or None) – The UID prefix to use when creating the UID. Default is the pydicom root UID
'1.2.826.0.1.3680043.8.498.'
. IfNone
then a prefix of'2.25.'
will be used with the integer form of a UUID generated using theuuid.uuid4()
algorithm.entropy_srcs (list of str or None) – If prefix is not
None
, then prefix will be appended with a SHA512 hash of thelist
which means the result is deterministic and should make the original data unrecoverable. IfNone
random data will be used (default).
- Returns
A DICOM UID of up to 64 characters.
- Return type
- Raises
ValueError – If prefix is invalid or greater than 63 characters.
Examples
>>> from pydicom.uid import generate_uid >>> generate_uid() 1.2.826.0.1.3680043.8.498.22463838056059845879389038257786771680 >>> generate_uid(prefix=None) 2.25.167161297070865690102504091919570542144 >>> generate_uid(entropy_srcs=['lorem', 'ipsum']) 1.2.826.0.1.3680043.8.498.87507166259346337659265156363895084463 >>> generate_uid(entropy_srcs=['lorem', 'ipsum']) 1.2.826.0.1.3680043.8.498.87507166259346337659265156363895084463