Today to do the invitation code this function, but I do not bother to modify the database table structure, and then read a lot of blogs on the internet, and then a blog above the PHP read a way to write, and then according to my understanding to rewrite into. Net. Words do not say more directly paste code.
static void Main (string[] args) {int num = 10086;
Console.WriteLine (Createcode (num));
Console.WriteLine (Decode (Createcode (num)));
Console.readkey ();
public static string Createcode (int Id) {String code = "";
String source_string= "2yu9ip6asdfg8qwerthj7klzx4cv5b3onm1";//Custom 35 int mod = 0;
StringBuilder sb = new StringBuilder ();
while (ID > 0) {mod = id% 35;
Id = (id-mod)/35; Code = source_string.
ToCharArray () [mod]+ code; Return code. PadRight (6, ' 0 ');/less than six-bit complement 0} public static int decode (string code) {code =new string (f Rom s in code where s!= ' 0 ' select s).
ToArray ());
int num = 0;
String source_string = "2YU9IP6ASDFG8QWERTHJ7KLZX4CV5B3ONM1"; for (int i = 0; i < code. ToCharArray (). Length; i++) {for (int j = 0; J < source_string. ToCharArray (). Length; J + +) {if (code. ToCharArray () [i]== source_string. ToCharArray () [j]) {num = J*convert.toint32 (Math.pow, code. ToCharArray ().
LENGTH-I-1));
}} return num; }
The advantage of this writing is that others do not know the order of your system, so it is difficult to reverse your user ID from the invitation code.
I'm just a rookie on the way to programming, and you are welcome to criticize me.