0

OK i know that question seem a duplicate while it's not. I've red the related questions. If I have a string (Base-64 encoded or not) how can i be assured that it is ? As you know if am gonna use the regex method then "test1111" shall be detected as Base-64. while in face, i want to capture only the true ((encoded)) Base-64 strings. I've red another method to catch the error and it's also same problem even if we try to encode it again to check equality. Note: i tagged many languages because i care only about the algorithm whatever language it is written with even if Pseudo code

Hasan
  • 86
  • 8
  • thanks for referring sir, while it's not. if you read further in the comments you will find that comment (This only tell that an input could have been a b64 encoded value, but it does not tell whether or not the input is actually a b64 encoded value. In other words, abcd will match, but it is not necessarily represent the encoded value of i· rather just a plain abcd input). which can explain my question in another way. – Hasan Feb 12 '16 at 03:09
  • @Hasan there is literally no possible way to tell the difference between whether "abcd" was encoded with Base64 or if it just happened to be the string that was sent. What you're asking for is _completely_ impossible. – Louis Wasserman Feb 12 '16 at 03:10
  • OK that's helpful Sir, but if so can you refer other encoding method rather than base64? which I can know using it if it's encoded with or normal string was sent. – Hasan Feb 12 '16 at 03:12
  • @Hasan probably not? Almost all encoding schemes can, by coincidence, come up with arbitrary strings. – Louis Wasserman Feb 12 '16 at 03:18
  • If you don't have some defined format of what the string must look like, you can only compare the raw data and the base64 decoded data and guess which one is more likely. `abcd` in your example sounds more likely than `i· ` (but I don't know your application). Why is this even a problem? Where does this uncertainty come from? – Thilo Feb 12 '16 at 03:24
  • am comparing to match GUID otherwise encodedID else URL which is normal string, and the encodedID can be generated only from the GUID not the URL, so when i compare a URL to find if it is an encoded one it says true while it is not. I think i need to change the design of this. – Hasan Feb 12 '16 at 03:34

0 Answers0