Questions tagged [secure-random]

SecureRandom is a Java class that provides a cryptographically strong random number generator (RNG).

SecureRandom is a Java class that provides a cryptographically strong random number generator (RNG).

A cryptographically strong random number minimally complies with the statistical random number generator tests specified in FIPS 140-2, Security Requirements for Cryptographic Modules, section 4.9.1. Additionally, SecureRandom must produce non-deterministic output. Therefore any seed material passed to a SecureRandom object must be unpredictable, and all SecureRandom output sequences must be cryptographically strong, as described in RFC 1750: Randomness Recommendations for Security.

http://docs.oracle.com/javase/7/docs/api/java/security/SecureRandom.html

84 questions
0
votes
1 answer

Test timeout doesn't work for hanged random number generator

I wrote a test to check if RNG is hanging public class StringUtilsTest { @Test @Timeout(value = 10) public void repeated_generateRandomStringOfDigits() { for (int i=0; i<5; ++i) { …
Dims
  • 47,675
  • 117
  • 331
  • 600
0
votes
1 answer

how to create hash value from random bytes using secureRandom equivalent class in C# using SHA-512

Equivalent code for this Java code in C# SecureRandom random = new SecureRandom(); byte randBytes[] = new byte[64]; random.nextBytes(randBytes); MessageDigest md = MessageDigest.getInstance("SHA-512"); md.update(randBytes); byte[] hash =…
Teja
  • 55
  • 5
0
votes
0 answers

Deterministic RNG for SecureRandom

SMEs, I have been following on various thread on SO how to make SecureRandom (java) deterministic with the help of a good entropy, but secret string as seed. Closest I got so far is the FixedRandom in bouncycastle which extends SecureRandom and…
tech_geek
  • 147
  • 2
  • 11
0
votes
0 answers

Remove NUL characters from byte array

in my code example i generate a random byte array that I have to use as salt with my password field. The problem occurs when in my byte array there is a NUL character. I have founded a way to remove this character using strings but for security…
0
votes
0 answers

Why is Intellij importing the "wrong" SecureRandom class (Java)?

I'm writing a programm that requires a SecureRandom objekt. After creating it, Intellij automatically imported "sun.security.provider.SecureRandom". But with this import, I'm unable to call many methods. For example I'm unable to "nextInt()" or…
HyperPro
  • 103
  • 2
0
votes
1 answer

Achieve new BigInteger(130, new SecureRandom()).toString(32) in JavaScript

I understand that we can use window.crypto to generate a secure random number, however window.crypto.getRandomValues() is using typedArray. May I know how can we achieve exactly this Java function in JavaScript: new BigInteger(130, new…
bao1202
  • 3
  • 4
0
votes
1 answer

Appropriate SecureRandom method for API token for use in URL?

I am aware that SecureRandom (ruby on rails) offers multiple methods for generating tokens Is there some method that is designed for urls? e.g. SecureRandom.hex(32) SecureRandom.base64(20) etc The main reason I ask is to ensure I don't…
stevec
  • 41,291
  • 27
  • 223
  • 311
0
votes
1 answer

Java Security API synchronized methods cause application threads to hang on high load

Our backend server is using Embedded Jetty 8.1.15 for few years now. Did not have any issues with it until recently, when we started doing load test scenario with a lot of concurrent users. Then we succeeded reproducing the issue even with small…
Romande
  • 561
  • 2
  • 4
  • 16
0
votes
0 answers

How to use SecureRandom with switches in Java

Okay, so I want to use this random number generator to output one case, instead it spits out all of them, what am I doing wrong? SecureRandom goodNumber = new SecureRandom(); int good = 1+ goodNumber.nextInt(4); switch(good){ case 1: …
Forrest
  • 157
  • 14
0
votes
1 answer

Empty securerandom.strongAlgorithms Security Property

When I am setting up as a application in Jenkins. The code works fine in local and other build environments. In Jenkins i am getting this error during the build and unit tests. Our application only needed external change is download JCE (Jave Crypto…
Kiran
  • 839
  • 3
  • 15
  • 45
0
votes
2 answers

SecureRandom setSeed method fails on MacOS

Running macOS High Sierra 10.13.5 and Java 1.8.0u171. I have something like the following code: SecureRandom random = SecureRandom.getInstance("NativePRNGNonBlocking"); random.setSeed(bla byte array); I encounter the following exception whenever…
ryanlutgen
  • 2,951
  • 1
  • 21
  • 31
0
votes
1 answer

JAVA Decode SHA1PRNG generated byte in hexa

I'm currently trying do implement a password hasher generator. But first, i'm trying to encode the randomly generated salt like this : public static byte[] generateSalt() throws NoSuchAlgorithmException { SecureRandom random =…
WaLinke
  • 726
  • 2
  • 6
  • 25
0
votes
0 answers

Ruby SecureRandom generating same result

Have a task that generates a uuid for each user, we use this as a external reference code. I created a rake task to create a PromoLink which generates a uuid for each user using rubys SecureRandom class: ActiveRecord::Base.transaction do …
legendary_rob
  • 12,792
  • 11
  • 56
  • 102
0
votes
1 answer

Java SecureRandom generate URL like Medium.com (Random 12 characters)

Instead of using the Long type do the Primary key, I found seems Medium.com using 12 characters. Can anyone let me know the algorithm or similar way to create it. For example: medium.com/**/nosuchmethoderror-in-log4j-issue-3a80f0c412c Hash (current…
dta.hoan
  • 83
  • 6
0
votes
1 answer

How to check if string is SecureRandom.urlsafe_base64(64)

The string: SecureRandom.urlsafe_base64(64) #=> "nItIZhCvbne9zjU4JUWJOL46y53ERfmuQQW_FN4_ymk2EdbQr1NYOXTJVIeUWXhvRCe4OU3Is2ZEaHpiXXGYxw" Random::Formatted.urlsafe_base64 implementation: def urlsafe_base64(n=nil, padding=false) s =…
Andrey Deineko
  • 51,333
  • 10
  • 112
  • 145