Generate static Pincode From Guid

Date: 2021-02-18

For simple verification without an extra field

var guidStr = Guid.Parse("890a1537-212f-4366-8d1d-95075b9245c4").ToString();

guidStr.Aggregate(0, (acc, x) => (acc + x * 1354) % 10000).ToString().PadLeft(4, '0');

// Results in: 7560
// Where 1354 can be changed per case
// And 10000 and PadLeft 4 to e.g. 100000 and 5 for codes with a length of 5

guidStr.Aggregate(0, (acc, x) => (acc + x * 1354) % 100000).ToString().PadLeft(5, '0');
// Results in: 97560

// Test some codes
for(int i=0;i<100;i++)
{
	Console.WriteLine(Guid.NewGuid().ToString().Aggregate(0, (acc, x) => (acc + x * 1351) % 100000).ToString().PadLeft(5, '0') );
}

// Examples:

05923
00545
19459
34294
92361
41127
80150
23434
82904
11353
55910
42374
55962
38321
09976
45128
45154
62639
51883
62665
19537
23538
26110
26136
54559
08625


46400cookie-checkGenerate static Pincode From Guid