using System.Security.Cryptography;
...
using(RandomNumberGenerator rng = new RNGCryptoServiceProvider())
{
byte[] tokenData = new byte[32];
rng.GetBytes(tokenData);
string token = Convert.ToBase64String(tokenData);
}
More Related Contents:
- Encrypt and decrypt a string in C#? [closed]
- Using AES encryption in C#
- How to read a PEM RSA private key from .NET
- Padding is invalid and cannot be removed?
- C# Export Private/Public RSA key from RSACryptoServiceProvider to PEM string
- How can I sign a file using RSA and SHA256 with .NET?
- Generate and Sign Certificate Request using pure .net Framework
- Which cryptographic hash function should I choose?
- C# RSA encryption/decryption with transmission
- Why use the C# class System.Random at all instead of System.Security.Cryptography.RandomNumberGenerator?
- How to store/retrieve RSA public/private key
- how to use RSA to encrypt files (huge data) in C#
- Encrypting/Decrypting large files (.NET)
- Encrypt cookies in ASP.NET
- Decrypt from SHA256
- Password encryption/decryption code in .NET
- C# SHA-1 vs. PHP SHA-1…Different Results?
- How to Generate Unique Public and Private Key via RSA
- Why do I need to use the Rfc2898DeriveBytes class (in .NET) instead of directly using the password as a key or IV?
- Calculating HMACSHA256 using c# to match payment provider example
- Compute a hash from a stream of unknown length in C#
- ‘Malformed Reference Element’ when adding a reference based on an Id attribute with SignedXml class
- Calculate primes p and q from private exponent (d), public exponent (e) and the modulus (n)
- Compare password hashes between C# and ColdFusion (CFMX_COMPAT)
- CryptographicException “Key not valid for use in specified state.” while trying to export RSAParameters of a X509 private key
- How to implement Triple DES in C# (complete example)
- find certificate on smartcard currently on reader
- SHA1 hashing in SQLite: how?
- Should these arguments be added or removed?
- Import a Public key from somewhere else to CngKey?