Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9261705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:11:50+00:00 2026-06-18T13:11:50+00:00

Hey guys I wanted to know if i could get a little help: Im

  • 0

Hey guys I wanted to know if i could get a little help: Im trying to count up in hex inside of a byte array. What im doing is i have the plain text in the form of 8 hex numbers and the cipher text in the same form as well as the first 4 numbers of the key. And im trying to use the DES to crack the key via brute force.

my key looks like this:

[A3 BB 12 44 __ __ __ __]

and i want it to start like this i suppose:

[A3 BB 12 44 00 00 00 00]

then

[A3 BB 12 44 00 00 00 01]

and so on. I just dont really know how to count in hex. inside of a byte array at that!

any help is much appreciated!

EDITED AFTER MUCH HELP

here is find key ( i changed some of the names of things around to better suit my program)

public static void findKey(){

    byte [] keyBytes = null;
    byte [] pt;
    byte [] ct;

    codeBreaker KEY = new codeBreaker(new byte[]{(byte)0x01, (byte)0x23, (byte)0x45, (byte)0x67, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00}, 2 );

    String plaintext = "Plaintxt";
    ct = new byte [] {(byte)0x4A, (byte)0xC4, (byte)0x55, (byte)0x3D, (byte)0xB3, (byte)0x37, (byte)0xCA, (byte)0xB3};

    //convert the plain text "Plaintxt" into a hex byte array
    String ptHex = asciiToHex(plaintext);
    pt = getBytes(ptHex);

    //keyBytes = KEY.inc()

    //my attempt
    /*while(!isKey(pt,keyBytes,ct)){
        KEY.inc(); // something like increase the key by 1 and send t back in.
    }
    */


    //this is your original while loop
    /*while (KEY.inc()) {
        byte[] bytes = KEY.getBytes();
        for (byte b: bytes) {
            System.out.printf("%02X ", b);
        }
        System.out.println();
    }
    */


    //Final outputs for the findKey method
    System.out.println("        Plain Text In Hex Is:");        
    printByteArray(pt);
    System.out.println();
    System.out.println("         The Cipher Text Is:");
    printByteArray(ct);
    System.out.println();

}

and here is the stuff you came up with

    public codeBreaker(byte[] keyAr, int startIndex) {
    this.key = keyAr;
    this.startIndex = startIndex;
}

   public boolean inc() {
   int i;
   for (i = key.length-1; i >= startIndex; i--) {
       key[i]++;
       if (key[i] != 0)
           break;
   }
        // we return false when all bytes are 0 again
   return (i >= startIndex || key[startIndex] != 0);
}

public byte[] getBytes() {
    return key;
}

which I all put into one class and called it codeBreaker with the rest of the methods i have (but those other ones dont have anything to do with this specific part)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T13:11:51+00:00Added an answer on June 18, 2026 at 1:11 pm

    What about this one?

    public class ByteIncrement
    {
        private final byte[] bytes;
        private final int startIndex;
        public ByteIncrement(byte[] bytes, int startIndex) {
            this.bytes = bytes;
            this.startIndex = startIndex;
        }
        public boolean inc() {
            int i;
            for (i = bytes.length-1; i >= startIndex; i--) {
                bytes[i]++;
                if (bytes[i] != 0)
                    break;
            }
            // we return false when all bytes are 0 again
            return (i >= startIndex || bytes[startIndex] != 0);
        }
        public byte[] getBytes() {
            return bytes;
        }
    
        public static void main(String[] args) {
            ByteIncrement bi = new ByteIncrement(new byte[]{(byte)0xa4, 0x56, 0x17, (byte)0x9f, 0x00, 0x00, 0x00, 0x00}, 2 ); // first two bytes are constant -> 2
            while (bi.inc()) {
                byte[] bytes = bi.getBytes();
                for (byte b: bytes) {
                    System.out.printf("%02X ", b);
                }
                System.out.println();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys I wanted to know if I get get some advice from some
Hey guys was hoping you could help me out. basically i'm working on a
hey guys was hoping you could help me out, Not sure if I always
Hey guys. I don't know much JS, but I wanted to do some quick
hey guys, this might be really stupid, but hopefully someone can help. I'm trying
Hey guys, I am a little confused as to how to get the T4
Hey guys, I wanted to know how to send data to a wordpress page
hey guys was hoping you could help me out. I am working on a
hey guys was hoping you could help me out.. The task seems simple but
Hey guys I wanted to create a JScrollPane but it won't work... and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.