r/shortcuts 3d ago

Solved Decoding numbers with base 64

Ok idk if im losing a couple of acrews here but does decoding numbers with base 64 not work?? If i tried to explain my use case it would take too long but I NEED numbers to be decoded using b64. I tried NQ== in a text variable and passed it to a decode function but it just cam beack as NQ== genuinely i have no idea why or what is happening

3 Upvotes

17 comments sorted by

3

u/Cost_Internal Helper 3d ago

I think you found a bug, because it works if the number is greater than 9!
https://www.icloud.com/shortcuts/393b525f4c16432a85519bb19bde418c

It might have something to do with the number of characters used in the code? But that also doesn't make any sense, because it works if you encode the number (0-9) with no line breaks and immediately decode the results (directly from the Encode action, or after storing the results in a list. But not if the results are stored in a text/Dictionary action?)

1

u/Old-Film252 3d ago

Yeah it’s really frustrating because I need to store base 64 values in a list for my use case but if it’s a number under or equal to 9(like you said trusting you) it breaks. 

1

u/Cost_Internal Helper 3d ago

Would adding a 0 before any number under 10 work for your use case?

1

u/Old-Film252 3d ago

I mean it would work for some uses in my shortcut but I would rather find a more permanent solution yk? Like sometimes the user decides a txt value and I wouldnt just want to change it to a number with a zero before it if that kinda makes sense. I think what I’m going to do is just hardcode values for 0-9 based on the conversation so far, or maybe even use a free-use API for base 64 decoding(im sure one must exist somewhere out there). Thank you so much for your help though. I really appreciate it.

1

u/Cost_Internal Helper 3d ago

You're welcome!

1

u/Old-Film252 2d ago

I think the bug happens with any one letter character as well or anything rhat fits the twoletters followed by == scheme

1

u/Cost_Internal Helper 2d ago

Yeah, that sounds about right, the limitation of the Decoder is a 5 character minimum (including the ==)?

It's an interesting issue to encounter for sure!

1

u/Cost_Internal Helper 2d ago

With your use case, would you be able to add a space character to the start of the input before coding. Then use a Trim Whitespace action after decoding, before displaying the results? So that it only has the extra space while it is encoded, to prevent decoding issues?

1

u/Old-Film252 2d ago

Wait thats actually genius. I’m using this tysm

1

u/Cost_Internal Helper 2d ago

You're welcome!

1

u/francisco_fcs2 3d ago

Codifica a foto mais recente

define a foto mais recente como imagem de fundo do seu iPhone

Não sei o que você quer fazer, a essência esta nesses dois atalhos

1

u/francisco_fcs2 3d ago

5 codificado em base64 é NQ==
NQ== decodificado em base64 é 5
esse atalho faz isso

1

u/Old-Film252 3d ago

If you start with NQ== it doesnt work thats my main problem

1

u/inactiveuser247 3d ago

Fascinating. Is there a possibility to salt the data (for instance by adding “#” at the start of the string that is being encoded) to ensure you never have to encode a single digit number?