무 작위 주민등록번호 생 성
6513 단어 주민등록증
1: /// <summary>
2: ///
3: /// </summary>
4: public class GenPinCode
5: {
6: public static string GetGenPinCode()
7: {
8:
9: System.Random rnd;
10: string[] _crabodistrict = new string[] { "350201", "350202", "350203", "350204", "350205", "350206", "350211", "350205", "350213" };
11:
12: rnd = new Random(System.DateTime.Now.Millisecond);
13:
14: //PIN = District + Year(50-92) + Month(01-12) + Date(01-30) + Seq(001-600)
15: string _pinCode = string.Format("{0}19{1}{2:00}{3:00}{4:000}", _crabodistrict[rnd.Next(0, 8)], rnd.Next(50, 92), rnd.Next(1, 12), rnd.Next(1, 30), rnd.Next(1, 600));
16: #region Verify
17: char[] _chrPinCode = _pinCode.ToCharArray();
18: //
19: char[] _chrVerify = new char[] { '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2' };
20: //i---- ;
21: //ai---- i ;
22: //Wi---- i , intWeight=2(n-1)(mod 11) 。
23: int[] _intWeight = new int[] { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 };
24: int _craboWeight = 0;
25: for (int i = 0; i < 17; i++)// 1 17 ,18
26: {
27: _craboWeight = _craboWeight + Convert.ToUInt16(_chrPinCode[i].ToString()) * _intWeight[i];
28: }
29:
30: _craboWeight = _craboWeight % 11;
31: _pinCode += _chrVerify[_craboWeight];
32: #endregion
33:
34: return _pinCode;
35: }
36: }