Example #1
0
        private static byte[] ConvertFromKey(string key, byte base2)
        {
            if (Base32Decoder.IsEmpty(key))
            {
                return(null);
            }
            uint num = (uint)Math.Floor((double)base2 / 8.0 * (double)key.Length);

            byte[] array = new byte[num];
            if (Base32Decoder.IsEmpty(array))
            {
                return(null);
            }
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = 0;
            }
            int  num2 = 0;
            int  num3 = key.Length - 1;
            byte b    = 0;

            while (num3 >= 0 && (long)num2 < (long)((ulong)(num * 8u)))
            {
                byte b2   = Base32Decoder.CharToVal(key[num3--]);
                int  num4 = (int)array[num2 / 8] + ((int)b2 << num2 % 8) + (int)b;
                b = (byte)(num4 / 256);
                array[num2 / 8] = (byte)(num4 % 256);
                num2           += (int)base2;
            }
            return(array);
        }
Example #2
0
 private static byte CharToVal(char c)
 {
     c = char.ToLower(c);
     if ('0' > c || c > '9')
     {
         return((byte)Base32Decoder.TrimNegative((int)((byte)(c - 'a' + '\n'))));
     }
     return((byte)Base32Decoder.TrimNegative((int)((byte)(c - '0'))));
 }
        public License Deserialize(string key, IDecoder decoder)
        {
            byte[]  data   = Base32Decoder.Decode(key);
            byte[]  buffer = decoder.Decode(data);
            License result;

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                License license = NewLicenseSerializer.ReadLicenseFromStream(memoryStream);
                result = license;
            }
            return(result);
        }
        public License Deserialize(string key, IDecoder decoder)
        {
            byte[] array = Base32Decoder.Decode(key);
            if (OldLicenseSerializer.IsEmpty(array))
            {
                return(null);
            }
            byte[] array2 = decoder.Decode(array);
            if (OldLicenseSerializer.IsEmpty(array2))
            {
                return(null);
            }
            License result;

            using (MemoryStream memoryStream = new MemoryStream(array2))
            {
                License license = OldLicenseSerializer.ReadLicenseFromStream(memoryStream);
                result = license;
            }
            return(result);
        }
Example #5
0
 public static byte[] Decode(string str)
 {
     return(Base32Decoder.ConvertFromKey(str, 5));
 }