Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /*
- little-endian ascii-bin to bin converter!
- Anything NOT ascii-bin ('1' or '0') is skipped
- authored (in 10 minutes) (unconventionally) in 2015 by: bazz | http://www.bazz1.com
- */
- char message[] = "00000000111111111101100011111111000000000000111000000000000000010000000000000000010010100100011000000000010010010100011000000000000000000000000000010000001000000000000000000000000000000110010000000000000000000110010000000000000000000000000000001111111111100000000000001100000000000001000100000000010001000111010101100011000000000000011010110111100100000000000000000000000000010000000000000000000001000000000000000000000000000000000000000110010000000000000000000000000000001111111100000000111000100000110001011000000000000000010010010100001101000000000000000011010111110101000000000000010100100100111101000110000000000000010010010100110001000000000000000101000000000000000100000000000000010000000000000000000000000000000011000100100001000000000000001100011010010110111000000000011011110000001000010000000000000000000000000000000001100000000000001101011011100111010000000000011100100101001001000111000000000000010000100010000001010000000000001000010110010101101000000000001000000000011111001110000000000000000000000000001000000000000000000000000010010000000000000000000001100000000000110001000000000000000000000000000001100000000000000001011000110111001100000000011100000100110101010011000000000000010001100101010000000000000000000000000000000000000000000000000000000100100101000101000000000000010000110010000001110000000000000011010100100100011100000000010000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111011000000000110101100000000000000001000000000000000000000000000000000000000000000000000000001101001100000000001011010100100001010000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000101100000000000000011011100000111001000000000011101000000000000000000000000000000000000010101000000000000000000000000000000000000000000000000001100110110010001100101000000000000011100110110001100000000000000000000000000000000000100000000100001000000000000000000000000000000000000000110110001110000000000000111011101000111000000000000011101000000000000000000000000000000000000011111000000000000000000000000000000000000000000000000000101000110001001101011000000000000011100000111010000000000000000000000000000000000001000000000000001000000000000000000000000000000000000000001010001110000000000000010010110000101100100000000010110100000000000000000000000000000000000100001100000000000000000000000000000000000000000000000000101000110011101011000000000000000010110010101101000000000000000000000000000000000001000000000001011000000000000000000000000000000000000000001010001100000000000000010010110000101100100000000010110100000000000000000000000000000000000100100000000000000000000000000000000000000000000000000000101000110010001101101000000000000011011100110010000000000000000000000000000000000001000000000010101000000000000000000000000000000000000000111000001100000000000000100011011010110010000000000011001000000000000000000000000000000000000101100010000000000000000000000000000000000000000000000100010000111011001110101000000000000011001010110010000000000000000000000000000000000001100000000010011000000000000000000000000000000000000001000011001110000000000000110011010010110010100000000011101110000000000000000000000000000000000111101010000000000000000000000000000000000000000000000001001000110110001110101000000000000011011010110100100000000000000000000000000000000001100000000111110000000000000000000000000000000000000000001010001100000000000001101011001010110000100000000011100110000000000000000000000000000000001000000110000000000000000000000000000000000000000000000001001000111010001100101000000000000011000110110100000000000000000000000000000000000010000000000001100000000000000000000000000000000000000000000110001110000000000000010010101000101001000000000010000110000000000000000000000000000000001000011110000000000000000000000000000000000100000000000000011000110011101010100000000000000010100100100001100000000000000000000000000000000010000000000001111000000000000000000000000000000000010000000110001100000000000000010010101000101001000000000010000110000000000000000000000000000000001000011110000000000000000000000000000000000100000000000000011000111010001100101000000000000011110000111010000000000000000000000000000000000000000000000000000000100001101101111000000000000011100000111100101110000000000000010011010010110011100000000011010000111010000100000000000000000001010000110001100100000000000001001001000000011000100000000001110010011100100111000000000000000001000000100100001100000000000000101011101110110110000000000011001010111010001110100000000000000001011010101000001100000000000000001011000110110101100000000011000010111001001100100000000000000001000000100001101100000000000001111011011010111000000000000011000010110111001111001000000000000000000000000000001100000000000000100011001010111001100000000011000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100100111001101010010000000000000010001110100001000100000000000000000010010010100010100000000010000110011011000110001000000000000001110010011011000110000000000000110001011010011001000000000001011100011000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000010011100110101001000000000010001110100001000100000000000000000010010010100010101000000000000000011001101100011000100000000001110010011011000110110000000000000001011010011001000100000000000001110001100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101100001011001000000000000010110100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100110101000100000000000000000000000000010000000000000000000000000000000000000001000000000000000101101100110001010000000000001000010110010101101000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101100001011001000000000000010110100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000011011111010001000000000000000000000000000000011100000000000111101010000000000000000000000000000000000111001000001010000000000001000010110010101101000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000110001000000000100110010000000000000000000000000000101101111000010100000000000000000000000000000001100000000000110110100101100001011001000000000000010110100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000001001001010000000000000000000000000000000000000111100000000100001000000000000000000000000000000101101101100111101100000000000000100011001010111001100000000011000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101100100100101000101";
- //char message[] = "00000001 00000010 11111111"; // ff0201 test
- char *lut[] =
- {
- "0000", // 0
- "0001", // 1
- "0010", // 2
- "0011", // 3
- "0100", // 4
- "0101", // 5
- "0110", // 6
- "0111", // 7
- "1000", // 8
- "1001", // 9
- "1010", // 10
- "1011", // 11
- "1100", // 12
- "1101", // 13
- "1110", // 14
- "1111" // 15
- };
- int main()
- {
- int x;
- // one byte at a time
- for (x=0; x < strlen(message); x)
- {
- // skip spaces or anything that's not binary ascii!
- if (message[x] != '1' && message[x] != '0')
- {
- x++; continue;
- }
- char final_byte=0;
- int i=0;
- char lo[4+1];
- char hi[4+1];
- // read 4
- hi[i++] = message[x++];
- hi[i++] = message[x++];
- hi[i++] = message[x++];
- hi[i++] = message[x++];
- hi[i] = 0;
- i=0;
- lo[i++] = message[x++];
- lo[i++] = message[x++];
- lo[i++] = message[x++];
- lo[i++] = message[x++];
- lo[i] = 0;
- for (i=0; i < 16; i++)
- {
- if (!strcmp(lo, lut[i]))
- {
- final_byte = i;
- }
- }
- for (i=0; i < 16; i++)
- {
- if (!strcmp(hi, lut[i]))
- {
- final_byte |= (i<<4);
- }
- }
- printf("%c", final_byte);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment