Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Binary Equals

Binary Equals

Scheduled Pinned Locked Moved C#
data-structuresquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Patricio Tapia
    wrote on last edited by
    #1

    byte[] comparar = new byte[16]; comparar[0] = 0x57; comparar[1] = 0x33; comparar[2] = 0x58; comparar[3] = 0x20; comparar[4] = 0x56; comparar[5] = 0x69; comparar[6] = 0x73; comparar[7] = 0x69; comparar[8] = 0x6f; comparar[9] = 0x6e; comparar[10] = 0x48; comparar[11] = 0x61; comparar[12] = 0x63; comparar[13] = 0x6b; comparar[14] = 0x20; comparar[15] = 0x31; byte[] regl = new byte[16]; bool emp = false; string FName = @"c:\W3XVisionHack12003.exe"; BinaryReader f = new BinaryReader(File.Open(FName,FileMode.Open),Encoding.ASCII); for (int i = 16; i <= f.BaseStream.Length; i++) { if (!emp) { for (int a = 0; a < 16; a++) regl[a] = f.ReadByte(); emp = true; } else { for (int a = 0; a < 15; a++) regl[a] = regl[a + 1]; regl[15] = f.ReadByte(); } if (regl == comparar) MessageBox.Show("Found"); } How i can comparate byte arrays? (my byte array with a BinaryReader byte array)

    A 1 Reply Last reply
    0
    • P Patricio Tapia

      byte[] comparar = new byte[16]; comparar[0] = 0x57; comparar[1] = 0x33; comparar[2] = 0x58; comparar[3] = 0x20; comparar[4] = 0x56; comparar[5] = 0x69; comparar[6] = 0x73; comparar[7] = 0x69; comparar[8] = 0x6f; comparar[9] = 0x6e; comparar[10] = 0x48; comparar[11] = 0x61; comparar[12] = 0x63; comparar[13] = 0x6b; comparar[14] = 0x20; comparar[15] = 0x31; byte[] regl = new byte[16]; bool emp = false; string FName = @"c:\W3XVisionHack12003.exe"; BinaryReader f = new BinaryReader(File.Open(FName,FileMode.Open),Encoding.ASCII); for (int i = 16; i <= f.BaseStream.Length; i++) { if (!emp) { for (int a = 0; a < 16; a++) regl[a] = f.ReadByte(); emp = true; } else { for (int a = 0; a < 15; a++) regl[a] = regl[a + 1]; regl[15] = f.ReadByte(); } if (regl == comparar) MessageBox.Show("Found"); } How i can comparate byte arrays? (my byte array with a BinaryReader byte array)

      A Offline
      A Offline
      Andrei Ungureanu
      wrote on last edited by
      #2

      DiNeSat4 wrote:

      if (regl == comparar)

      In this way you compare the instances of the 2 objects. If you want to compare 2 arrays you have to compare each element within those arrays

      private bool AreEqual(byte[] a, byte[] b)
      {
      if (a.Length != b.Length)
      return false;
      for (int i = 0 ; i < a.Length ; i++)
      if (a[i] != b[i])
      return false;
      return true;
      }

      Hope it helps.

      Do your best to be the best

      P 1 Reply Last reply
      0
      • A Andrei Ungureanu

        DiNeSat4 wrote:

        if (regl == comparar)

        In this way you compare the instances of the 2 objects. If you want to compare 2 arrays you have to compare each element within those arrays

        private bool AreEqual(byte[] a, byte[] b)
        {
        if (a.Length != b.Length)
        return false;
        for (int i = 0 ; i < a.Length ; i++)
        if (a[i] != b[i])
        return false;
        return true;
        }

        Hope it helps.

        Do your best to be the best

        P Offline
        P Offline
        Patricio Tapia
        wrote on last edited by
        #3

        Damn men, thanks you i'm happy :D five stars to you :D :rose:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups