0

I have a String which contains some encoded values in some way like Base64.

The problem is that I really don't know if it's actually Base64 (there are A-Z, a-z. 0-9, +, /) so it can be some any other code that i'm not familiar with.

Is there a way or any other online site to send him an encoded input and it can tell me in which code is it?

NOTE: I'm not asking how to know if my String is UTF-8 or iso-8859-1 or something like that. What I need is to know in which is my code is encoded.

EDIT:

To be more clear,

I need something to get an input like: 23Nzi4lUE4qlc+Pmc3blWMS1Irmgo3i8UTQHhoL7VyzqpEV/i9bDhoiteZ0a7/TqcVSkrXR89V2Yj7tEFDGJx4gvWEBs= this is the encoded String that I have.

The output should be the type of the encoded String and it's decoding like:

Base64 -> "Big yellow fish is swimming in the tube."

Maybe there is some program which get's an input and tries to decode it with a list of coding types (Base64 and etc.). The output doesn't really matter because it's the users decision if it's good or not.

The Dr.
  • 556
  • 1
  • 11
  • 24
  • 2
    Try every possible encoding that you know and are prepared to handle in order. If it decodes using a particular encoding, it was *probably* encoded in that encoding. It really is exactly the same thing as trying to guess UTF-8, ISO-8859 or any other kind of encoding. – deceze Jul 01 '15 at 09:54
  • Is the expected output known? – user2864740 Jul 01 '15 at 10:33
  • No, and the coded type isn't known also – The Dr. Jul 01 '15 at 10:35
  • 1
    I assume you are asking because a simple 'decodes without errors' does not meet your needs. However, what are your needs? Do you know how your plaintext must/mustn't look like? Imho, you won't get a reliably good solution without consulting information beyond the encoded data stream. – collapsar Jul 01 '15 at 10:57
  • I don't mind have one with errors, this only tells me that my input is not meets the output so this is not the encoding scheme that I'm looking for. – The Dr. Jul 01 '15 at 12:10

1 Answers1

0

This site handles base64 de/encoding.

Since Base64 is just one instance of a class of encoding schemes ( specifically, encoding a bit stream as base_<n> number ), you probably will never fare better than testing for just a couple of standard encoding schemes.

You either check the well-formedness of the encoding scheme or try to decode without getting an error thrown using a web service or your own code.

In (possibly pathological) cases there will be more than one encoding scheme for which a given octet stream will successfully decode.

Best practice would be to take the effort invested into setting up the verification to committing the data provider to one (or 'a few') encoding(s) first (won't always be possible, of course).

collapsar
  • 17,010
  • 4
  • 35
  • 61
  • I saw this site before I asked this question, and it's good for me. I'm asking how to detect the type of the encoding, to know if it's Base64 or any other... – The Dr. Jul 01 '15 at 10:04
  • In short, you can't. The reason is that, dependent on the usage scenario, any string in a given encoding may be considered plaintext - think documentation or malicious attackers. Moreover, many (rather most) 'encodings' of the kind you are interested in don't provide the encoded data stream with sufficient characteristics to allow a _reliable_ detection. What you can do is indeed informed guessing: identify required/prohibited data stream properties, try to decode. Still, all you get are hints. The more reliability you need, the better it is to commit the data provider to a specific workflow. – collapsar Jul 01 '15 at 10:43
  • It seems to be that you're right. But maybe there some program which getting my input and runs it all over coding type such as Base64, if the output is right or wrong it doesn't matter just print what comes out. Do you know anything like that? – The Dr. Jul 01 '15 at 10:48
  • What do you mean by 'such as' ? There are infinitely many conceivable encoding schemes. Anyway, i do not know of a software addressing your task beyond the trivial combination of individual decoders. – collapsar Jul 01 '15 at 11:06
  • I meant about all the encoding schemes which are more popular (I know that there are infinitely) like Base64 and etc. – The Dr. Jul 01 '15 at 12:07
  • Try [this service](http://decode.urih.com/). It supports uude/encode,quoted-printable and percent-encoding (as used in query string parts of uris). Can't comment on the quality,it just showed up on a google search ... Btw, your sample doesn't decode. The actual B64 encoding is `QmlnIHllbGxvdyBmaXNoIGlzIHN3aW1taW5nIGluIHRoZSB0dWJlLg==`. – collapsar Jul 01 '15 at 12:33