Skip to content

Commit f3722bf

Browse files
committed
feat: add addition alphabets to random string
1 parent d789693 commit f3722bf

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Core.Common.Standard/KY.Core.Common.Standard.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<RootNamespace>KY.Core</RootNamespace>
66
<AssemblyName>KY.Core.Common</AssemblyName>
7-
<Version>4.34.1</Version>
7+
<Version>4.35.0</Version>
88
<Authors>KY-Programming</Authors>
99
<Company>KY-Programmingp</Company>
1010
<Product>KY.Core</Product>
@@ -36,6 +36,9 @@
3636
<AutoGen>True</AutoGen>
3737
<DependentUpon>Resources.resx</DependentUpon>
3838
</Compile>
39+
<Compile Remove="Nuget\AssemblyLocation.cs" />
40+
<Compile Remove="Nuget\AssemblyLocator.cs" />
41+
<Compile Remove="Nuget\AssemblySearchParameters.cs" />
3942
</ItemGroup>
4043

4144
<ItemGroup>

Core.Common.Standard/Random2.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ namespace KY.Core
88
public static class Random2
99
{
1010
private static readonly Random random = new Random();
11-
private static string defaultAlphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-!?@";
11+
public const string DefaultAlphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-!?@";
12+
public const string Base64Alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/";
13+
public const string Base32Alphabet = "abcdefghijklmnopqrstuvwxyz234567";
14+
public const string Base36Alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
15+
public const string UrlSafeAlphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
1216

1317
public static string NextString(int minLength = 5, int maxLength = 25, string alphabet = null)
1418
{
15-
alphabet = alphabet ?? defaultAlphabet;
19+
alphabet ??= DefaultAlphabet;
1620
int length = random.Next(minLength, maxLength);
1721
StringBuilder builder = new StringBuilder(length);
1822
for (int i = 0; i < length; i++)
@@ -64,4 +68,4 @@ public static IList<T> Unorder<T>(IList<T> list)
6468
return list.OrderBy(x => order[x]).ToList();
6569
}
6670
}
67-
}
71+
}

0 commit comments

Comments
 (0)