update to use cryptographic random if it is available

- fix coding rule.
- change environment check code to use ENVIRONMENT_IS_NODE.