Use integer maths to convert bits to bytes.

This commit is contained in:
akwizgran
2014-01-16 18:02:34 +00:00
parent 14e1cd6072
commit f97039318a

View File

@@ -171,7 +171,7 @@ class CryptoComponentImpl implements CryptoComponent {
}
public int generateInvitationCode() {
int codeBytes = (int) Math.ceil(CODE_BITS / 8.0);
int codeBytes = (CODE_BITS + 7) / 8;
byte[] random = new byte[codeBytes];
secureRandom.nextBytes(random);
return ByteUtils.readUint(random, CODE_BITS);