-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
259 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -351,4 +351,5 @@ MigrationBackup/ | |
|
||
.vs/ | ||
bin/ | ||
obj/ | ||
obj/ | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# FakeData | ||
# FakeSharp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
namespace FakeSharp | ||
{ | ||
public class CreditCard | ||
{ | ||
/// <summary> | ||
/// Bin码类型 | ||
/// </summary> | ||
public enum BinType | ||
{ | ||
Any = 0, | ||
GongShang = 623062, | ||
ZhongGuo = 621343, | ||
JianShe = 622676, | ||
ZhaoShang = 410062, | ||
ZhongXin = 433680, | ||
GuangDa = 622663, | ||
MinSheng = 622622, | ||
JiaoTong = 621335, | ||
PingAn = 622989, | ||
NongYe = 622848 | ||
} | ||
|
||
|
||
/// <summary> | ||
/// 生成银行卡号 | ||
/// </summary> | ||
/// <param name="binType">Bin码类型</param> | ||
/// <param name="length">银行卡号长度</param> | ||
/// <param name="count">生成数量</param> | ||
/// <returns></returns> | ||
public static IEnumerable<string> Generate(BinType binType = BinType.Any, int length = 16, int count = 100) | ||
{ | ||
var fakeCardNumber = 0L; | ||
var fakeCardNumbers = new string[count]; | ||
var r = new Random(DateTime.Now.Second + DateTime.Now.Millisecond); | ||
|
||
for (int i = 0; i < count; i++) | ||
{ | ||
// 生成bin码 | ||
if (binType == BinType.Any) { fakeCardNumber = (int)GenerateRandomBinCode(r); } | ||
else { fakeCardNumber = (int)binType; } | ||
|
||
// 添加中间位 | ||
fakeCardNumber += (long)(fakeCardNumber * Math.Pow(10, length - 7)) + r.Next((int)Math.Pow(10, length - 8), (int)(0.9 * Math.Pow(10, length - 7))); | ||
|
||
// 计算校验位 | ||
var sum = 0L; | ||
var isDoubleBit = true; | ||
|
||
var fakeCardNumberCopy = fakeCardNumber; | ||
while (fakeCardNumberCopy > 0) | ||
{ | ||
if (isDoubleBit) | ||
{ | ||
sum += SelfSum((fakeCardNumberCopy % 10) * 2); | ||
} | ||
else | ||
{ | ||
sum += fakeCardNumberCopy % 10; | ||
} | ||
|
||
isDoubleBit = !isDoubleBit; | ||
fakeCardNumberCopy /= 10; | ||
} | ||
|
||
var res = sum % 10; | ||
if (res != 0) { res = 10 - res; } | ||
|
||
// 构造银行卡号 | ||
fakeCardNumbers[i] = $"{fakeCardNumber}{res}"; | ||
} | ||
|
||
return fakeCardNumbers; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// 随机生成Bin码 | ||
/// </summary> | ||
/// <param name="r"></param> | ||
/// <returns></returns> | ||
static BinType GenerateRandomBinCode(Random? r = null) | ||
{ | ||
if (r == null) { r = new Random(DateTime.Now.Second + DateTime.Now.Millisecond); } | ||
return r.Next(10) switch | ||
{ | ||
0 => BinType.GongShang, | ||
1 => BinType.ZhongGuo, | ||
2 => BinType.JianShe, | ||
3 => BinType.ZhaoShang, | ||
4 => BinType.ZhongXin, | ||
5 => BinType.GuangDa, | ||
6 => BinType.MinSheng, | ||
7 => BinType.JiaoTong, | ||
8 => BinType.PingAn, | ||
9 => BinType.NongYe, | ||
_ => BinType.Any | ||
}; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// 求整数中每位数字之和 | ||
/// </summary> | ||
/// <param name="n"></param> | ||
/// <returns></returns> | ||
static long SelfSum(long n) | ||
{ | ||
var sum = n % 10; | ||
var rest = n; | ||
|
||
while ((rest /= 10) > 0) | ||
{ | ||
sum += rest % 10; | ||
} | ||
|
||
return sum; | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace FakeSharp | ||
{ | ||
public class IdentifyCard | ||
{ | ||
|
||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
namespace FakeSharp | ||
{ | ||
/// <summary> | ||
/// 手机号码生成器 | ||
/// </summary> | ||
public class MobileNumber | ||
{ | ||
static readonly int[] MAC_CHINA_MOBILE = { 134, 135, 136, 137, 138, 139, 150, 151, 152, 157, 158, 159, 182, 187, 188}; | ||
static readonly int[] MAC_CHINA_UNICOM = { 130, 131, 132, 155, 156, 182, 185, 186 }; | ||
static readonly int[] MAC_CHINA_TELECOM = { 133, 153, 180, 189 }; | ||
static readonly int[] MAC_CHINA_ALL = { 134, 135, 136, 137, 138, 139, 150, 151, 152, 157, 158, 159, 182, 187, 188, 130, 131, 132, 155, 156, 182, 185, 186, 133, 153, 180, 189 }; | ||
|
||
|
||
/// <summary> | ||
/// 生成手机号码 | ||
/// </summary> | ||
/// <param name="macConfig">移动接入码</param> | ||
/// <param name="count">生成数量</param> | ||
/// <returns></returns> | ||
public static IEnumerable<string> Generate(MAC macConfig = MAC.Any, int count = 100) | ||
{ | ||
var r = new Random(DateTime.Now.Second + DateTime.Now.Millisecond); | ||
var fakeNumbers = new string[count]; | ||
for(int i = 0; i < count; i++) | ||
{ | ||
int mac = macConfig switch | ||
{ | ||
MAC.ChinaMobile => MAC_CHINA_MOBILE[r.Next(MAC_CHINA_MOBILE.Length)], | ||
MAC.ChinaUnicom => MAC_CHINA_UNICOM[r.Next(MAC_CHINA_UNICOM.Length)], | ||
MAC.ChinaTelecom => MAC_CHINA_TELECOM[r.Next(MAC_CHINA_TELECOM.Length)], | ||
_ => MAC_CHINA_ALL[r.Next(MAC_CHINA_ALL.Length)], | ||
}; | ||
fakeNumbers[i] = $"{mac}{r.Next(10000000, 89999999)}"; | ||
} | ||
return fakeNumbers; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// 移动接入码(移动、联通、电信) | ||
/// </summary> | ||
public enum MAC | ||
{ | ||
Any = 0, // 任意 | ||
ChinaMobile, // 中国移动 | ||
ChinaUnicom, // 中国联通 | ||
ChinaTelecom // 中国电信 | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="FakeSharp"> | ||
<HintPath>..\lib\bin\Release\net6.0\FakeSharp.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.