Ejemplo n.º 1
0
        public static void SaveToDisk(this XpsFont font, string path)
        {
            using (Stream stm = font.GetStream())
            {
                using (FileStream fs = new FileStream(path, FileMode.Create))
                {
                    byte[] dta = new byte[stm.Length];
                    stm.Read(dta, 0, dta.Length);
                    if (font.IsObfuscated)
                    {
                        string guid = new Guid(font.Uri.GetFileName().Split('.')[0]).ToString("N");
                        byte[] guidBytes = new byte[16];
                        for (int i = 0; i < guidBytes.Length; i++)
                        {
                            guidBytes[i] = Convert.ToByte(guid.Substring(i * 2, 2), 16);
                        }

                        for (int i = 0; i < 32; i++)
                        {
                            int gi = guidBytes.Length - (i % guidBytes.Length) - 1;
                            dta[i] ^= guidBytes[gi];
                        }
                    }
                    fs.Write(dta, 0, dta.Length);
                }
            }
        }
Ejemplo n.º 2
0
    public static string GenerateKey()
    {
        string timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff");
        string key = null;
        using (MD5 md5 = MD5.Create())
        {
            byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(timestamp));
            key = new Guid(hash).ToString();
        }

        return key.Substring(0,18);
    }
        private void CreateWorkspaceItemToRegister(string id, string parentId, bool folder, string text)
        {

            string title = FormatTitle(text);
            var props    = new WorkspaceItemProperty[CAmountProps];
            var descs    = new WorkspaceItemDescription[CAmountDesc];
            int subIndex;
            string idHex;
            string idGuid;

            subIndex = (_index * 10) + 1;
            for (int i = 0; i < CAmountProps; i++)
            {
                idGuid = new Guid(subIndex, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).ToString();
                idHex = idGuid.Substring(6, 2);
                props[i] = new WorkspaceItemProperty
                {
                    Id = idGuid,
                    ItemId = id,
                    PropertyName = String.Format("Property({0}) - {1} of {2}", idHex, i + 1, CAmountProps),
                    PropertyValue = String.Format("Property value({0}) - {1} of {2}", idHex, i + 1, CAmountProps),
                    PropertyTypeId = _itemPropertyTypeId,
                    PropertyTypeDescription = String.Format("Property description({0}) - {1} of {2}", subIndex, i + 1, CAmountProps)
                };
                subIndex++;
            }
            subIndex = (_index * 10) + 1;
            for (int i = 0; i < CAmountDesc; i++)
            {
                idGuid = new Guid(subIndex, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).ToString();
                idHex = idGuid.Substring(6, 2);
                descs[i] = new WorkspaceItemDescription
                {
                    CultureId = CultureInfo.CurrentCulture.Name,
                    Id = idGuid,
                    ItemId = id,
                    Title = String.Format("Description({0}) - {1} of {2}", idHex, i + 1, CAmountDesc),
                    TypeId = _itemDescriptionTypeId
                };
                subIndex++;
            }
            _items[_index++] = new WorkspaceItem { Id = id, ParentId = parentId, ItemId = id, TypeId = (folder ? _treeViewFolderTypeId : _treeViewLeafTypeId), ItemTitle = title, Descriptions = descs, Properties = props, DateModified = DateTime.Now };
        }
Ejemplo n.º 4
0
		static byte[] DeobfuscateFont(XpsFont font)
		{
			using (var stm = font.GetStream())
			{
				byte[] dta = new byte[stm.Length];
				stm.Read(dta, 0, dta.Length);
				if (font.IsObfuscated)
				{
					string guid = new Guid(System.IO.Path.GetFileNameWithoutExtension(font.Uri.ToString())).ToString("N");
					byte[] guidBytes = new byte[16];
					for (int i = 0; i < guidBytes.Length; i++)
						guidBytes[i] = Convert.ToByte(guid.Substring(i * 2, 2), 16);

					for (int i = 0; i < 32; i++)
					{
						int gi = guidBytes.Length - (i % guidBytes.Length) - 1;
						dta[i] ^= guidBytes[gi];
					}
				}
				return dta;
			}
		}