The different types reflect directly the usage (and the allowed ranges).
wifi.recv() will often handle binary data, while base64_dec_len() inherently only works on text.
The type system flags conversions that could create problems,
if you know what you are doing (and you should if you use casts) its OK.
I see no problem in extracting/converting a number or a base64 ASCII-string,
even if it resides in a 'binary' buffer.
So the cast can be seen as an oath that the content is compatible.