This commit is contained in:
35
util/fetchkeycode.cs
Normal file
35
util/fetchkeycode.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
|
||||
namespace rockfishCore.Util
|
||||
{
|
||||
//Generate a random code for license key fetching
|
||||
//doesn't have to be perfect, it's only temporary and
|
||||
//requires knowledge of the customer / trial user
|
||||
//email address to use it so it's kind of 2 factor
|
||||
public static class FetchKeyCode
|
||||
{
|
||||
|
||||
public static string generate()
|
||||
{
|
||||
|
||||
//sufficient for this purpose
|
||||
//https://stackoverflow.com/a/1344258/8939
|
||||
|
||||
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
var stringChars = new char[10];
|
||||
var random = new Random();
|
||||
|
||||
for (int i = 0; i < stringChars.Length; i++)
|
||||
{
|
||||
stringChars[i] = chars[random.Next(chars.Length)];
|
||||
}
|
||||
|
||||
var finalString = new String(stringChars);
|
||||
return finalString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
Reference in New Issue
Block a user