Skip to content

Commit

Permalink
Lazily instantiate SHA1HashMixerRNG
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed Jul 13, 2017
1 parent e79c871 commit 6b73008
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mongodb/vibe/db/mongo/sasl.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import vibe.crypto.cryptorand;

@safe:

private SHA1HashMixerRNG g_rng;
private SHA1HashMixerRNG g_rng()
{
static SHA1HashMixerRNG m_rng;
if (!m_rng) m_rng = new SHA1HashMixerRNG;
return m_rng;
}

package struct ScramState
{
Expand Down Expand Up @@ -150,8 +155,3 @@ private DigestType!SHA1 pbkdf2(const ubyte[] password, const ubyte[] salt, int i
}
return current;
}

static this()
{
g_rng = new SHA1HashMixerRNG();
}

0 comments on commit 6b73008

Please sign in to comment.