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 7726181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:09:01+00:00 2026-06-01T05:09:01+00:00

I have an object called users that I use to store user objects that

  • 0

I have an object called users that I use to store user objects that have credential information.

I call this code to make a new default user.

user def = new user("admin","admin",md5hash(("osa").toCharArray()),1,-1);

This def user is added to the array.

These users are stored inside an array. When I loop through the array to check whether it is valid or not, I use this snippet of code to output information about users inside the array, namely the username and password in string format from a byte array.

System.out.println(userarray.get(x).username);
System.out.println((userarray.get(x).password).toString());

The passwords are all encrypted in md5 and stored as a byte array using this code:

byte[] md5hash(char[] passwd) {
    String passwdtext = new String(passwd);
byte[] passdigest = null;
    try {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.reset();
        md5.update(passwdtext.getBytes("UTF-8"));
        passdigest = md5.digest();

    } catch (NoSuchAlgorithmException e) {

        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return passdigest;
}

When I try entering “admin” for user and “osa” for the password, I output these as well and compare them with the values in the array

I get the following:

admin [B@2b12e7f7

and compare to the value inside the array:
admin [B@663b1f38

Why are they different?

  • 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-01T05:09:03+00:00Added an answer on June 1, 2026 at 5:09 am

    The toString() byte array does not encode the data. What you are looking at is the memory address of said arrays. The “[B” means byte array. The hex after that is the address.

    Instead, you should invoke Arrays.toString(digestArray); which will print the actual values in the array.

    Also, it’s not clear by the code that you posted, but if you’re trying to use == to compare the two arrays, that will fail for the same reason. The == operator on arrays compares memory addresses. Here again, you should use Arrays.equals(a1, a2) to compare.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey. I have an object that has a string property called BackgroundColor. This string
I have an instance variable called users defined as NSMutableArray . I use that
Here is the scenario: I have an object called a Transaction that needs to
I have a UITableView that displays various nsstrings from a custom object called a
I have an object with a property called name. This object has a sub
I have a data object -- a custom class called Notification -- that exposes
Say I have an object called data which contains a variety of information. Let's
I have an object class called BOM. It has a method, getChildItem() which returns
I have an NSDate object called 'dueDate'. I'm trying to work out how to
I have a collection of an object called Bookmarks which is made up of

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.