diff --git a/src/main/java/com/github/davidcarboni/cryptolite/Random.java b/src/main/java/com/github/davidcarboni/cryptolite/Random.java
index <HASH>..<HASH> 100644
--- a/src/main/java/com/github/davidcarboni/cryptolite/Random.java
+++ b/src/main/java/com/github/davidcarboni/cryptolite/Random.java
@@ -105,7 +105,8 @@ public class Random {
             @Override
             public int read() throws IOException {
                 if (count++ < length) {
-                    return Byte.toUnsignedInt(bytes(1)[0]);
+                    return ((int) bytes(1)[0]) & 0xff;
+                    // For Java 8: return Byte.toUnsignedInt(bytes(1)[0]);
                 } else {
                     return -1;
                 }
Tweaked to work with a Java 7 compiler.