How to generate UID for any table?

Hi,

We are trying to insert data in table using script for which we need to generate UID as well as XObjectKey. I tried searching for OOTB system scripts if we can reuse it and generate UID but could not find it. Can you please help? Thank you.