Take a look at the source of Arrays.hashCode and just copy/paste it here, but with an offset and length as a parameter. Then take the above code for getSaltedKey and make one byte array that's the right size initially (not right now you're assuming that the key starts at offset 0)