Ejemplo n.º 1
0
        internal static byte[] ByteArrayFromKey(string Key)
        {
            if (Key.Length != keyLengthSeperated)
            {
                throw new InvalidLicenseException("License key is invalid");
            }

            byte [] returnArray       = new byte[keyLength];
            char [] charArray         = Key.ToCharArray();
            int     seperationCounter = 0;
            int     returnArrayIndex  = 0;

            foreach (char keyCharacter in charArray)
            {
                if (seperationFrequency != seperationCounter++)
                {
                    returnArray[returnArrayIndex++] = LicenseCharacterConvertor.ValueOf(keyCharacter);
                }
                else
                {
                    seperationCounter = 0;
                }
            }

            return(returnArray);
        }
Ejemplo n.º 2
0
        internal static string KeyFromByteArray(byte [] ByteArray)
        {
            if (ByteArray.Length > keyLength)
            {
                throw new InvalidLicenseException("License key is invalid");
            }

            int           seperationCounter = 0;
            StringBuilder sb = new StringBuilder(keyLengthSeperated, keyLengthSeperated);

            foreach (byte myByte in ByteArray)
            {
                if (seperationFrequency == seperationCounter++)
                {
                    sb.Append(seperator);
                    seperationCounter = 1;
                }
                sb.Append(LicenseCharacterConvertor.CharacterValue(myByte));
            }
            return(sb.ToString());
        }