pydicom.uid.generate_uid¶
-
pydicom.uid.
generate_uid
(prefix: Optional[str] = '1.2.826.0.1.3680043.8.498.', entropy_srcs: Optional[List[str]] = None) → pydicom.uid.UID[source]¶ 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, optional) – The UID prefix to use when creating the UID. Default is the pydicom root UID
'1.2.826.0.1.3680043.8.498.'
. If not used 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, optional) – If prefix is used then the prefix will be appended with a SHA512 hash of the supplied
list
which means the result is deterministic and should make the original data unrecoverable. If entropy_srcs isn’t used then random data will be appended instead (default). If prefix is not used then entropy_srcs has no effect.
- 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