3

I need a function that generates a random number from 0 to n for the lottery. I found 2 ways to do that:
1. https://gist.github.com/alexvandesande/259b4ffb581493ec0a1c But miners can influence the number by not publishing a block with an unwanted outcome
2. Use JSON-RPC random.org with oraclize.it But oraclize is centralized service.
So, which is the safest way to generate a random number?