Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/goterl/lazycode/lazysodium/LazySodium.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private static byte[] hexToBytes(String s) {
//// -------------------------------------------|

@Override
public byte randomBytesRandom() {
public long randomBytesRandom() {
return getSodium().randombytes_random();
}

Expand All @@ -164,7 +164,7 @@ public byte[] nonce(int size) {
}

@Override
public byte randomBytesUniform(int upperBound) {
public long randomBytesUniform(int upperBound) {
return getSodium().randombytes_uniform(upperBound);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/goterl/lazycode/lazysodium/Sodium.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public native int sodium_base642bin(byte[] bin,
//// RANDOM
//// -------------------------------------------|

public native byte randombytes_random();
public native long randombytes_random();

public native byte randombytes_uniform(int upperBound);
public native long randombytes_uniform(int upperBound);

public native void randombytes_buf(byte[] buffer, int size);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
public interface Random {

/**
* Return a random byte 0 and 0xffffffff included.
* Return a unsigned int byte 0 and 0xffffffff included.
* @return A random byte.
*/
byte randomBytesRandom();
long randomBytesRandom();

/**
* Returns an unpredictable value between 0 and upperBound (excluded).
* Unlike randombytes_random() % upper_bound, it guarantees a uniform distribution
* of the possible output values even when upper_bound is not a power of 2. Note
* that an upper_bound less than 2 leaves only a single element to be chosen, namely 0.
* @param upperBound
* @return A uniformally random bytes.
* @return A uniformly random unsigned int.
*/
byte randomBytesUniform(int upperBound);
long randomBytesUniform(int upperBound);

/**
* Get a random number of bytes.
Expand Down