blob: b54da2061eda8dbf95865cf1790c105e8e00ddba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
//-----------------------------------------------------------------------
// <copyright file="StandardTokenGenerator.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOAuth.ChannelElements {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
internal class StandardTokenGenerator : ITokenGenerator {
RandomNumberGenerator cryptoProvider = new RNGCryptoServiceProvider();
#region ITokenGenerator Members
public string GenerateRequestToken(string consumerKey) {
return GenerateCryptographicallyStrongString();
}
public string GenerateAccessToken(string consumerKey) {
return GenerateCryptographicallyStrongString();
}
public string GenerateSecret() {
return GenerateCryptographicallyStrongString();
}
#endregion
private string GenerateCryptographicallyStrongString() {
byte[] buffer = new byte[20];
cryptoProvider.GetBytes(buffer);
return Convert.ToBase64String(buffer);
}
}
}
|