Thread: 32 Byte Hex Converted To 2 byte??

  1. #1
    Registered User
    Join Date
    Nov 2018
    Posts
    9

    32 Byte Hex Converted To 2 byte??

    Hello,
    I have been looking around the Internet and I cant really find what I am looking for. I was wondering if you guys can help me out and I will try to make this as clear as I can.

    I have this long hex string in 2 byte form:
    0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052, 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058
    Binary:
    00000100 00110001,00000000 00000000,00000001 01010100,00000001 01010011,00000001 01010001,00000001 01010111,00000000 01010001,00000000 01010010,00000001 01100000,00010000 00100000,00000000 01110101,00100001 10010111,00000001 01010010,00000001 01011000,00000000 01010111,00000000 01011000,




    Now have this other hex string that controls the long hex string:
    BF FF

    So if you are thinking yes BF controls one half and FF controls the other:
    BF = 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052
    Bin = 00000100 00110001,00000000 00000000,00000001 01010100,00000001 01010011,00000001 01010001,00000001 01010111,00000000 01010001,00000000 01010010,

    FF = 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058
    Bin= 00000001 01100000,00010000 00100000,00000000 01110101,00100001 10010111,00000001 01010010,00000001 01011000,00000000 01010111,00000000 01011000,

    Now I know for sure if I change BF FF to 00 00 this happens:
    BF to 00 = 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000
    Bin = All Zeros
    FF to 00 = 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000
    Bin = All Zeros

    And if I do this 00 FF this happens:
    BF to 00 = 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000
    Bin = All Zeros
    FF = 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058
    Bin= 00000001 01100000,00010000 00100000,00000000 01110101,00100001 10010111,00000001 01010010,00000001 01011000,00000000 01010111,00000000 01011000,

    I know this a lot of info but I am trying to be as clear as I can lol. Ok so now my question, is there a C code that can determine the BF sequence?

    If BF = 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052 what does C1 equal?

    Let say I want to do this:
    0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052 change to 0431, 0000, 0154, 0153, 0000, 0157, 0000, 0052 what will I change BF to then??

    0431, 0000, 0154, 0153, 0000, 0157, 0000, 0052 = ??

    If the long hex needs to 1 byte like so, then cool:
    04, 31, 00, 00, 01, 54, 01, 53, 01, 51, 01, 57, 00, 51, 00, 52
    00000100, 00110001, 00000000, 00000000, 00000001, 01010100, 00000001, 01010011, 00000001, 01010001, 00000001, 01010111, 00000000, 01010001, 00000000, 01010010,

    The commas are to help to visual see what bin is goes to which hex. In nutshell I guess, there a way in C to input the hex (or bin if need be) and it will calculate to the correct shortened/converted BF or BF FF?

    Thanks,
    Kevin.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Let me see if I have gathered your relationship correctly.
    You have a bunch of numbers (four bits each). The shorter string is obtained by making any nonzero number into a 1 and any zero into a 0. Yes?

    If so, then you can do something like
    Code:
    int result = 0;
    for (however many numbers)
        result <<= 1;
        if (number)
            result += 1;

  3. #3
    Registered User
    Join Date
    Nov 2018
    Posts
    9
    Quote Originally Posted by tabstop View Post
    Let me see if I have gathered your relationship correctly.
    You have a bunch of numbers (four bits each). The shorter string is obtained by making any nonzero number into a 1 and any zero into a 0. Yes?

    If so, then you can do something like
    Code:
    int result = 0;
    for (however many numbers)
        result <<= 1;
        if (number)
            result += 1;
    I would think so, I know 00 changes the whole string to Zeros and I know that BF is 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052. And sorry for my lack of knowledge I am only 2 weeks in learning C. My new job has pulled me back into programming but I have not done so since 2012! Lol If is not a hassle if you could provide a bit more coding? Some changing BF to any range from 00 to FF changes the long hex.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Are you trying to generate the long stuff from BF FF or the other way around? Or do you have a big long number, and a BF FF, and then a new big long number that has some zeroes in it?

  5. #5
    Registered User
    Join Date
    Nov 2018
    Posts
    9
    Quote Originally Posted by tabstop View Post
    Are you trying to generate the long stuff from BF FF or the other way around? Or do you have a big long number, and a BF FF, and then a new big long number that has some zeroes in it?
    I have both, there are many that are like this, I just kept it simple. Which ever is the best way. Here is a bit more
    BF FF = 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052, 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058
    Then another
    BF FF = 0421, 0000, 0134, 0133, 0131, 0137, 0031, 0032, 0140, 1022, 1023, 2195, 0132, 0138, 0037, 0038
    EB DB = 0000, 0000, 0401, 0462, 0442, 0000, 0033, 0510, 0551, 0441, 0000, 0451, 0461, 0000, 0128, 0442
    And like before EB controls the first half and DB control the other half. And I 00 00 these the long hex strings change 0000 for each.

    If best to convert for short string to long then cool but of long to short it is better then fine, I have both. I just need too know... You know what... I need long to short i.e.:
    EB DB = 0000, 0000, 0401, 0462, 0442, 0000, 0033, 0510, 0551, 0441, 0000, 0451, 0461, 0000, 0128, 0442

    I input 0000, 0000, 0401, 0462, 0442, 0000, 0033, 0510, 0551, 0441, 0000, 0000, 0000, 0000, 0128, 0000 = what? its not EB DB.

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Turbo7 View Post
    I input 0000, 0000, 0401, 0462, 0442, 0000, 0033, 0510, 0551, 0441, 0000, 0000, 0000, 0000, 0128, 0000 = what? its not EB DB.
    Well, if you write 1 if you have a number and 0 if you have zero, you get 00111011 11000010, which is 0x3b c2. This is the code-like object I posted above.

    As you can see, it's not a reversible operation, since we have two different "results" for BF FF; but they must have the 0000 in the same place.

  7. #7
    Registered User
    Join Date
    Nov 2018
    Posts
    9
    Quote Originally Posted by tabstop View Post
    Well, if you write 1 if you have a number and 0 if you have zero, you get 00111011 11000010, which is 0x3b c2. This is the code-like object I posted above.

    As you can see, it's not a reversible operation, since we have two different "results" for BF FF; but they must have the 0000 in the same place.
    So if it's not reversible that mean I cant find out what I need?

    If I take:
    0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052, 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058
    to
    0431, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000
    BF FF should be something like B0 00 or 80 00 right? If so, how do I get there.

    I want to put in:
    0431, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000
    and get
    "The Correct Output"
    Can this not be done in C?

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Turbo7 View Post
    So if it's not reversible that mean I cant find out what I need?
    If you have the original, and the control string, then you can get to the result. But you need both of the inputs.
    Quote Originally Posted by Turbo7 View Post
    I want to put in:
    0431, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000
    and get
    "The Correct Output"
    Can this not be done in C?
    Not without specifying the 0x80 00 (or whatever pattern you need).

  9. #9
    Registered User
    Join Date
    Nov 2018
    Posts
    9
    Quote Originally Posted by tabstop View Post
    If you have the original, and the control string, then you can get to the result. But you need both of the inputs.

    Not without specifying the 0x80 00 (or whatever pattern you need).
    So with me having BF FF and 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052, 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058 I cant find out the sequence on how BF FF equals 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052, 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058?

    So therefore I stuck, I know for a fact that someone has figured out the BF FF sequence but you know things like this people keep to themselves.

    As far as 80 00 that was some random sequence I picked. So a bit more info 00 00 mean off (do not display number) and BF FF mean on (display number in long hex string i.e. 0154), if want to not to display 0154 only would would need the correct BF FF sequence, therefor BF FF is no longer BF FF it is something else, and that else is what I am looking for.

  10. #10
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Turbo7 View Post
    So with me having BF FF and 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052, 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058 I cant find out the sequence on how BF FF equals 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052, 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058?

    So therefore I stuck, I know for a fact that someone has figured out the BF FF sequence but you know things like this people keep to themselves.

    As far as 80 00 that was some random sequence I picked. So a bit more info 00 00 mean off (do not display number) and BF FF mean on (display number in long hex string i.e. 0154), if want to not to display 0154 only would would need the correct BF FF sequence, therefor BF FF is no longer BF FF it is something else, and that else is what I am looking for.
    I'm not sure I've got another different explanation in me, but I'll try. There are two inputs and one output:
    Code:
    input 1 (?????) : 0431 GGGG 0154 0153 0151 0157 0051 0052 0160 1020 0075 2197 0152 0158 0057 0058
    input 2 (BF FF) :  on  off  on   on   on   on   on   on   on   on   on   on   on   on   on   on
    ---------
    output  (above) : 0431 0000 0154 0153 0151 0157 0051 0052 0160 1020 0075 2197 0152 0158 0057 0058
    The on/off pattern from input 2 is just the binary representation of BF FF. The GGGG represent some input value that you haven't bothered to tell anybody; and because the whole point of this process is to mask off numbers and make them 0000, you can't tell just from the result what those original values were. The thing you need to realize before we can really go anywhere with this thread is that the long string you have is the output, not the input. As long as you think of them as input, we're just going to keep going around in this same circle.

  11. #11
    Registered User
    Join Date
    Nov 2018
    Posts
    9
    Quote Originally Posted by tabstop View Post
    I'm not sure I've got another different explanation in me, but I'll try. There are two inputs and one output:
    Code:
    input 1 (?????) : 0431 GGGG 0154 0153 0151 0157 0051 0052 0160 1020 0075 2197 0152 0158 0057 0058
    input 2 (BF FF) :  on  off  on   on   on   on   on   on   on   on   on   on   on   on   on   on
    ---------
    output  (above) : 0431 0000 0154 0153 0151 0157 0051 0052 0160 1020 0075 2197 0152 0158 0057 0058
    The on/off pattern from input 2 is just the binary representation of BF FF. The GGGG represent some input value that you haven't bothered to tell anybody; and because the whole point of this process is to mask off numbers and make them 0000, you can't tell just from the result what those original values were. The thing you need to realize before we can really go anywhere with this thread is that the long string you have is the output, not the input. As long as you think of them as input, we're just going to keep going around in this same circle.
    Ok this looks good, so

    Code:
    input 1 (?????) : 0431 GGGG 0154 0153 0151 0157 0051 0052 0160 1020 0075 2197 0152 0158 0057 0058
    input 2 (BF FF) :  on  off  on   on   on   on   on   on   on   on   on   on   on   on   on   on
    ---------
    output  (above) : 0431 0000 0154 0153 0151 0157 0051 0052 0160 1020 0075 2197 0152 0158 0057 0058
    To this:
    Code:
    input 1 (?? ??) : 0431 GGGG 0154 0153 0151 0157 0051 GGGG 0160 1020 0075 2197 0152 0158 0057 0058
    input 2 (BF FF) :  on  off  on   on   on   on   on   off   on   on   on   on   on   on   on   on
    ---------
    output 1 (?? ??) : 0431 0000 0154 0153 0151 0157 0051 0000 0160 1020 0075 2197 0152 0158 0057 0058
    output 2 (?? ??) :  on  off  on   on   on   on   on   off   on   on   on   on   on   on   on   on
    Also 0000 that you called GGGG i did not change that, it is there by default.

  12. #12
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Turbo7 View Post
    Also 0000 that you called GGGG i did not change that, it is there by default.
    The 0000 is there only because the B byte masked it off; it is (almost certainly) not the original starting value.

  13. #13
    Registered User
    Join Date
    Nov 2018
    Posts
    9
    Quote Originally Posted by tabstop View Post
    The 0000 is there only because the B byte masked it off; it is (almost certainly) not the original starting value.
    As far as being original, it original according the .hex file I am working with. Here is snippet of what I am looking at. The big table on the right is a reference table only, the left table is the control. Now keep in mind when you change the table on the left does not change the right it just a reference table. I have tested this and when threw all the of the left table and change to 00 00 one by one (took forever lol) and tested on the bench I have (it shows certain numbers on the right table), therefore knowing that BF is one half and the FF is another and same for all the others, in short BF turns on or off 8 numbers in a row in the right table. I.E. BF controls 0431 to 0052 as stated before, but the right table does not change. So I cannot change one or any of the numbers in the right table and the and see the change in the left.

    This is why I was looking for some code to find the correct sequence.
    32 Byte Hex Converted To 2 byte??-table-png

  14. #14
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    So if changing the right table doesn't affect the left table, and changing the left table doesn't affect the right table, why do you think they are related?

    Most of these lines do follow the right pattern of on-off matching the hex on the left table, but there are a few exceptions.

  15. #15
    Registered User
    Join Date
    Nov 2018
    Posts
    9
    Quote Originally Posted by tabstop View Post
    So if changing the right table doesn't affect the left table, and changing the left table doesn't affect the right table, why do you think they are related?

    Most of these lines do follow the right pattern of on-off matching the hex on the left table, but there are a few exceptions.
    I noticed that too so thinking the left needs to be changed a bit. But need the left sequence.

    They are related in the fact the right table is a visual reference (a look up table that is in order with left table controller), I.E. on my bench numbers 0270, 0267, 0264, 0261 are showing, which is Left table 9 rows up from the bottom, 10 to the right, with that you can see the numbers line up with the left table with 0F FF which is 6 up from the bottom, Now when I changed 0F FF to 0F 00 those number turned off on my bench, and noticed that numbers are all in a row. See what I mean? That why said they are related and its a reference table.

    Thank you for all your help and trying to understand I am trying to get done!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 01-22-2016, 03:20 AM
  2. File Comparision byte by byte
    By anusha2489 in forum C Programming
    Replies: 12
    Last Post: 05-16-2011, 06:58 AM
  3. reading files byte by byte
    By cpsc in forum C++ Programming
    Replies: 12
    Last Post: 01-07-2011, 03:54 PM

Tags for this Thread