Reputation: 2970
Im looking for a way to decode a string encrypted in base32 back to original string in mysql. I know there is a SP to do this with base64 but cannot find anything for base32.
Is it possible? is there a stored procedure I can use somewhere?
What are ways to implement this?
Thanks!
Upvotes: 2
Views: 3524
Reputation: 406
BASE 64 or BASE 32 are not encrypted, they are just encoded. MySQL does not have a native function to perform encoding/decoding of Base 32 strings as it has for Base 64, FROM_BASE_64 e TO_BASE_64.
As an alternative you can try the CONV mathematical function (depending on the content stored as BASE32). Lets say you have UUID numbers stored as DECIMAL and need to show them as BASE32 or vice versa:
SELECT uuid, conv(uuid, 10, 32) uuid_b32, conv(conv(uuid, 10, 32), 32, 10)
FROM database.table;
The answer above is for number conversions between distinct base. If that is not the case, as when you have a binary file stored on a blob column, them you'll probably need to do the encoding/decoding outside MySQL. You may use MIME::Base32 or the proper module on your preferred language. Anyway, you'll need to know if the field has text or binary encoded in Base32.
Upvotes: 4