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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:54:46+00:00 2026-05-31T09:54:46+00:00

I am getting a random number in My android client as well as Server(Servlet).

  • 0

I am getting a random number in My android client as well as Server(Servlet). I am using the same SecureRandom algorithm(“SHA1PRNG”) in both client and server. My seed value is same for both. But the output number I am getting is different in both client as well as Server. What could be the reason for it? Here is my code:

SecureRandom random = new SecureRandom();
try {
    random.getInstance("SHA1PRNG");
} catch (Exception e) {
    // ...
}
;
random.setSeed(1097327);
byte[] b1 = new byte[3];
random.nextBytes(b1);
long value = 0;
for (int i = 0; i < b1.length; i++) {
    value += (b1[i] & 0xff) << (8 * i);
    Toast.makeText(getApplicationContext(), Long.toString(value),
            Toast.LENGTH_LONG).show();
}
  • 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-05-31T09:54:47+00:00Added an answer on May 31, 2026 at 9:54 am

    The javadoc of SecureRandom says:

    Many SecureRandom implementations are in the form of a pseudo-random
    number generator (PRNG), which means they use a deterministic
    algorithm to produce a pseudo-random sequence from a true random seed.
    Other implementations may produce true random numbers, and yet others
    may use a combination of both techniques.

    Maybe the algorithm uses another randomness source to produce its random numbers. Doing it would not break the contract of the SecureRandom class. It would even satisfy it even more, since the goal of a secure random generator is to produce random numbers, and not a predictable sequence of numbers.

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

Sidebar

Related Questions

I am getting random row from my table using the following query: SELECT value_id
I understand that time is an insecure seed for random number generation because it
I am having a problem requesting a random number from random.org using jQuery. When
When I am compiling this program I am getting some random number as output..
I'm getting a random unreproducible Error when initializing a JSplitPane in with JDK 1.5.0_08.
I have a problem getting boost::multi_index_container work with random-access and with orderd_unique at the
I want to log some seemingly random errors I'm getting in a Delphi written
I'm running into a scenario where at random times I am getting Access Denied
Getting started with NHibernate How can I generate identity fields in nHibernate using Hilo
To get a random whole number between 0 and 4 inclusive, I use the

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.