Skip to content

GenerateUrlSafeSecret Method ​

Definition ​

  • Namespace: JASE.Crypto
  • Assembly: JASE.Crypto.dll

string GenerateUrlSafeSecret(int length = null) ​

csharp
string GenerateUrlSafeSecret(int length = null)

Generates a cryptographically secure random secret encoded as unpadded Base64URL.

Parameters ​

NameDescription
lengthThe number of random bytes to generate before encoding.

Returns ​

A Base64URL-encoded secret containing only letters, digits, -, and _.

Remarks ​

32 bytes = 256 bits of entropy, which is a strong default for passwords, shared secrets, and client credentials when the receiving system accepts arbitrary string values.