here is an example of random binary code :

000000000110000001100000000000000000000001000000
000100000000000001110000001001000010000001101001
000100000000000000101001011001010110010000100000
000000000000000001010100000000000110001000100001
001011000110000001010000001000000010100100000010
000000000000000000001001000000100111010000100001
010000000110000101000010000101000110000101000110
001000000010000000000100000000100001011100000101

the code above is only for clarity and specification

my question is :

how to decode a random binary code to plain text ???????

and what are , generally , the methods used to decode a random binary code????

"Plain text" is ambiguous. You'd need to determine what text encoding method is used (eg. ASCII or UTF-8). Not all encodings will use a leading byte order mark to tell you what you have, so some trial and error may be necessary.

If it's just assumed to be ASCII, a straight lookup of each byte against an ASCII table would be sufficient. As an example in C++:

#include <bitset>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    const char *s =
        "000000000110000001100000000000000000000001000000"
        "000100000000000001110000001001000010000001101001"
        "000100000000000000101001011001010110010000100000"
        "000000000000000001010100000000000110001000100001"
        "001011000110000001010000001000000010100100000010"
        "000000000000000000001001000000100111010000100001"
        "010000000110000101000010000101000110000101000110"
        "001000000010000000000100000000100001011100000101";

    for (const char *x = s; *x != '\0'; x += 8) {
        cout.put((char)bitset<8>(string(x, x + 8)).to_ulong());
    }
}

However, that produces garbage, so the bytes probably aren't ASCII unless your example really is random.

"You'd need to determine what text encoding method is used (eg. ASCII or UTF-8)"

it is binary encoding method only that there is two problem. The first is that we do not know how many bits represent a character so that we do not make mistakes by getting weird characters. The second we do not know the type of binary encryption used to encrypt the code above.

"Not all encodings will use a leading byte order mark to tell you what you have, so some trial and error may be necessary"

therefore how to know , to check , to detect the type of encryption used in the code above as well as in any sophisticated encrypted code??????

"However, that produces garbage, so the bytes probably aren't ASCII unless your example really is random."

do you have doubts in my words??? if you read carefully , when I post my question I wrote : "here is an example of random binary code"

"how to decode a random binary code to plain text ???????" ...I told you it is random binary code and I put it in bold

any suggestion or help about the code above ?????

it is binary encoding method

Obviously. I meant what the binary represents when presented as character glyphs.

The first is that we do not know how many bits represent a character

That falls under the text encoding. ASCII is a 7 bit encoding and is stored in 8 bits. UTF-8 can be between 1 and 4 bytes. UTF-16 is 2 bytes, etc... But once you know what the encoding is, you can figure out how many bytes represent a single character the same way everyone else does: the rules of the encoding.

The second we do not know the type of binary encryption used to encrypt the code above.

You neglected to mention that we're looking at encrypted text and not plain text. That adds a whole other dimension to the problem. Now it's an cryptography theory problem, and for that I'll direct you to your nearest book store because that's a rather broad and intense field of study.

if you read carefully , when I post my question I wrote : "here is an example of random binary code"

I always read carefully, and I didn't miss that part of your post. If you read carefully, did you mention that the binary is encrypted? That drastically changes the nature of your question.

One thing that might help is write the bytes to a file and use a Hex Editor to see what the individual bytes are. Decoding from binary is in a class all its own, since you have no idea how many bits make up a byte and how many bytes make up an encoded byte.

ok my question how to decode a random binary code to plain text ??????? has no sense :
a random binary code cannot be decode because it cannot be encoded because text to binary encoding requires code unit which is a specific sequence of bits that form one character . like that when we want to decode a binary to text we need to know the code unit . if it is random so there is no specific code unit so we cannot decode it

let us forget about my earlier no sense question.

here what is important piece of code earlier is part of a large complete code :

000000000110000001100000000000000000000001000000
000100000000000001110000001001000010000001101001
000100000000000000101001011001010110010000100000
000000000000000001010100000000000110001000100001
001011000110000001010000001000000010100100000010
000000000000000000001001000000100111010000100001
010000000110000101000010000101000110000101000110
001000000010000000000100000000100001011100000101
011010000010100000100000011001000000000100000000
010000100010111000000000011101000000001000100000
000101000110000001000001001000000000011000100100
010110000111010000100000001000110111010001000001
001001110100010000001100000000000100011000100011
001000000111010001001000011000010101000001000101
001100100000100100001010000000000010000100000000
000100000011000100100001001100000011000000010000
000100010010000000000000001000010000000000100000
001100010001000000000000000000000010000000110000
000000010001000000010001000000000001000000110001
000000000000000100110000000000000010000000001101
000010000001000000010000001000000010000000110000
000000010000000000000001001000000001000100100000
000100000010000100010001000000010001000000110000
000100010011000000000000000100010000000000000000
000100000000000000000001001000010000000000110000
001100010000000000110000000010000000000000000000
000000000001000100110000001000000001000100000000
001100000001000000100001001100000001000000100000
001100000011000000010001001000000010000000010000
000100000010000000000000000000000001000000100000
000100000011000000010001000000000010000000010000
000100000000100000001000001000000011000000010000
000100000000000000000000000100000011000000000000
001100010010000100010001000000000001000000000000
000000000011000000010001001100010011000000000001
001100000001000000110000000000000001000000010001
001100000001000000110000000000000001000000000001
00000000

this is a text to binary encoded code

I want to know what is the type of encoding used in this large code

it is none of these :

us-ascii
utf-8
utf-16
utf-7
utf-32
ansi
base64
base32

so what is the encoding?

I never thought that binary code convertation is such hard work

it is hard because there is a trick ; a special skill in encoding and decoding some binary codes. Unless you know this mysterious trick , you will never be able to decode it whatsoever and howsoever you try

If it is not random, it might be encrypted code.

ddanbe , I want to ask if it is possible to talk with you online , I mean live chat

is it possible??

For the moment OK

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.