From 353b8f083465624ac4149c936dce97acb39b1ba0 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 12 Jan 2020 15:24:39 +0000 Subject: [PATCH] Add thread-local secureRandom property --- .../dev/openrs2/common/crypto/ThreadLocalSecureRandom.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 common/src/main/java/dev/openrs2/common/crypto/ThreadLocalSecureRandom.kt diff --git a/common/src/main/java/dev/openrs2/common/crypto/ThreadLocalSecureRandom.kt b/common/src/main/java/dev/openrs2/common/crypto/ThreadLocalSecureRandom.kt new file mode 100644 index 00000000..09fce084 --- /dev/null +++ b/common/src/main/java/dev/openrs2/common/crypto/ThreadLocalSecureRandom.kt @@ -0,0 +1,8 @@ +package dev.openrs2.common.crypto + +import java.security.SecureRandom + +private val threadLocal = ThreadLocal.withInitial { SecureRandom() } + +val secureRandom: SecureRandom + get() = threadLocal.get()