0

I am working on a Spring Boot application having a legacy third party db in which I can't do any schema change. In one of my api I am receiving UUID v4 having length of 36 character which i need to store in table column of varchar(20).

Also I have to decode the column value to UUID while returning response of api.

Can anyone suggest the way to achieve the same.

Thanks

Manish
  • 1,274
  • 3
  • 22
  • 59
  • 1
    Does [this](https://stackoverflow.com/questions/772802/storing-uuid-as-base64-string) answer your question? I think [base85](https://en.wikipedia.org/wiki/Ascii85) is the way to go. – Tasos P. Aug 27 '20 at 08:25
  • @Cascader I tried on https://cryptii.com/pipes/ascii85-encoding but it's encoding to 45 characters. – Manish Aug 27 '20 at 08:54
  • You need to encode the actual bytes of the UUID, not the string (hex) representation of it. UUID is 16 bytes which can be base-85 to 20 characters. Its canonical textual representation is 32 characters (36 if you include the dashes) which you probably encoded to 45 characters. – Tasos P. Aug 27 '20 at 09:00
  • @Cascader can you please share some java library to encode into base85. I tried and found some github link but not sure if they are reliable to use in production environment – Manish Aug 27 '20 at 09:54

0 Answers0