Hi,
I am trying to create a unique hash from some concatenated strings so that I can use the hash as a Primary Key in my database.
It is preferable to have the hash as an alphanumeric value.
To achieve this I was planning to use the code below.
byte2hex(sha( "SOME_LONG_STRING_VALUE" ));
I was wondering if there might be a better way to achieve this (in CTL if possible). Any suggestion will be appreciated.
Thank you,
Shubha
I do not believe so. But you can create your CTL function which will implement code you proposed.
Also, if you’d not require hash you may consider function
randomUUID()
Hello Shubha,
it appears that your question has already been answered. Nevertheless, let me mention another option for the sake of approach diversity. If you did not insist on using a hash function, you could take advantage of the persistent sequence functionality in Clover. A persistent sequence generates unique numbers across graph runs so if you run a graph more times, you will get different sequence numbers in each graph run. Attached is an example graph where I demonstrate the usage of a persistent sequence for the purpose of building up a unique alphanumeric key. The idea is to concatenate the sequence number with a string (in this case a snippet of the string field content, but it could be essentially any string with no special characters).
If your use case is more specific, feel free to get back to us with more details and we can investigate which approach would be optimal in your case.
Kind regards,