# Background to RNG implementations

**URL:** <https://discuss.akka.io/t/background-to-rng-implementations/2025>\
**Category:** Akka Libraries\
**Created:** [August 31, 2018, 11:23pm UTC](https://discuss.akka.io/t/background-to-rng-implementations/2025 "2018-08-31T23:23:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wsargent](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/wsargent/32/118_2.png) [@wsargent](https://discuss.akka.io/u/wsargent)\
**Post date:** [August 31, 2018, 11:23pm UTC](https://discuss.akka.io/t/background-to-rng-implementations/2025/1 "2018-08-31T23:23:56Z")

</div>

> **[Broken random number generators AES128CounterSecureRNG /...](https://doc.akka.io/docs/akka/current/security/2018-08-29-aes-rng.html)**
>
> Akka is a toolkit for building highly concurrent, distributed, and resilient message-driven applications for Java and Scala.

> The exact historical reasons to include custom RNG implementations could not be reconstructed but it was likely because RNGs provided by previous versions of the JDK were deemed too slow.

Yes, this is the case, referencing

> <https://github.com/akka/akka/issues/12636>
>
> imported from https://www.assembla.com/spaces/akka/tickets/2636
> 
> math.uncommons …is used to implement a crypto provider to replace the flawed SecureRandom based seed generator in Java. It could be completely replaced by a small amount of Scala code.

> <https://github.com/akka/akka/pull/21730#discussion_r85521305>
>
> Seems like there is a performance impact of that still, compared to AES-CTR RNG.

> <https://github.com/akka/akka/pull/21716>
>
> This PR is intended to discuss the possible replacement of AES256CounterRNG by a…lternative built-in function doing the same.

---

<div class="post-metadata">

**Author:** ![patriknw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/patriknw/32/89_2.png) [@patriknw](https://discuss.akka.io/u/patriknw)\
**Post date:** [September 1, 2018, 7:57am UTC](https://discuss.akka.io/t/background-to-rng-implementations/2025/2 "2018-09-01T07:57:10Z")

</div>

Thanks Will. Those RNGs shouldn’t have been included in Akka in the first place, and that was a mistake. Security must be preferred over performance. As far as I understand a custom implementation can be installed via the ordinary SecurityProvider if someone really wants that, but it shouldn’t be part of Akka.

A good article that you linked to before is [https://tersesystems.com/blog/2015/12/17/the-right-way-to-use-securerandom/](https://tersesystems.com/blog/2015/12/17/the-right-way-to-use-securerandom/)
