summaryrefslogtreecommitdiff
path: root/WinKeyRecover/keyManager/CheckIsValid.cs
blob: 5b6775b3a84fd0dccc2b10e6c3b17f0487baa616 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinKeyRecover
{
    internal class CheckIsValid
    {
        private string key;

        public bool CheckKey(char[] validChars, string key)
        {
            this.key = key.ToUpper();

            if (this.key != string.Empty 
                && this.key.Length == 29 
                && this.key.Contains('*')
                )
            {
                for (int i = 0; i < key.Length; i++)
                {
                    if (this.key[i] != '-'
                        && this.key[i] != '*'
                        && !validChars.Contains(this.key[i]) 
                        )
                    {
                        return false;
                    }
                }
            }
            else
            {
            return false;
            }

            return true;
        }
    }
}