You need to sign in to do that
Don't have an account?
Saikishore Reddy Aengareddy
Generate Unique String
Hello,
I have a requirement where I will have to convert a unique 64 character string to a unique 20 character string.
Eg:
Input:abcdef57AgYi8oPidnskd908234ksdjsdjlsdjksd092kj
Output: asdf123asdf123asdf12
Everytime i give the same input i should get the same output. We have around 5+ Million records to be updated.
Please let me know if you have any ideas around solving the problem.
Thanks.
Create an MD5 hash and only take the first 20 characters of the hash.
Hi Scott,
How can you be sure that first 20 characters will make string unique? I think MD5 encrypted string is 32 characters long. According to me, taking only first 20 characters will not work. What do you think?
Thanks
Sounds great to me but our bussiness rejected this solution. Bummer!
I have a similar problem. I need to supply a unique five-character value to a web service.
I'll explain the code below.
In-case the value returned by the timestamp is rejected by the server, I'm using the last character as a retry-counter. The first retry would be 1, the second 2, and so on.
For example, if the first was rejected and the second was required it would generate OF6WF30 then OF6WF31.
Because Apex lacks radix methods anywhere I can find, I'm not keen on translating the string back to a long to add one to it to try again--though that wouldn't be too hard.
Of course, even with base36 my string is still 7-characters long. Perhaps I should add some puntuation characters.