/// <summary> /// Convert the KeyList object to a composite key /// </summary> /// <param name="kList">KeyList containing the composite key information.</param> /// <returns>CompositeKey object.</returns> internal static CompositeKey ConvertToComposite(KeyList kList) { if (kList.Pass == null || kList.KeyName == null) { return(null); } int kNumber = kList.Pass.Count(); int i = 0; CompositeKey mKey = new CompositeKey(); for (i = 0; i < kNumber; ++i) { switch (kList.KeyName[i]) { case "KeePassLib.Keys.KcpPassword": byte[] pb = kList.Pass[i].ReadUtf8(); IUserKey mKeyPass = new KcpPassword(pb); MemUtil.ZeroByteArray(pb); mKey.AddUserKey(mKeyPass); break; case "KeePassLib.Keys.KcpKeyFile": IUserKey mKeyFile = new KcpKeyFile(kList.Pass[i].ReadString()); mKey.AddUserKey(mKeyFile); break; case "KeePassLib.Keys.KcpUserAccount": IUserKey mKeyUser = new KcpUserAccount(); mKey.AddUserKey(mKeyUser); break; } } return(mKey); }
public CompositeKey GetCompositeKey(KeyCipher keyCipher) { var password = keyCipher.UnProtect(_protectedPassword); var compositeKey = new CompositeKey(); foreach (var data in _keys) { IUserKey key = null; byte[] rawData = null; if (data.KcpType != KcpType.kcpUserAccount) { rawData = keyCipher.Decrypt(data.EncryptedData, password); } try { switch (data.KcpType) { case KcpType.kcpCustomKey: key = new KcpCustomKey(data.CustomName, rawData, false); break; case KcpType.kcpPassword: key = new KcpPassword(rawData); break; case KcpType.kcpKeyFile: key = new KcpKeyFile(Encoding.UTF8.GetString(rawData)); break; case KcpType.kcpUserAccount: key = new KcpUserAccount(); break; } } finally { if (rawData != null) { MemUtil.ZeroByteArray(rawData); } } Debug.Assert(key != null); compositeKey.AddUserKey(key); } return(compositeKey); }
private static void GenerateEms(StringBuilder sb, PwDatabase pd, string strDbFile, GFunc <string, string> h, GFunc <string, string> ne, GFunc <string, string> ltrPath, string strFillInit, string strFillInitEx, string strFillEnd, string strFill) { sb.AppendLine("<p><strong>" + h(KPRes.DatabaseFile) + ":</strong></p>"); sb.AppendLine(strFillInitEx + ne(h(ltrPath(strDbFile))) + strFillEnd); // if(pd.Name.Length > 0) // sb.AppendLine("<p><strong>" + h(KPRes.Name) + ":</strong> " + // h(pd.Name) + "</p>"); // if(pd.Description.Length > 0) // sb.AppendLine("<p><strong>" + h(KPRes.Description) + ":</strong> " + // h(pd.Description)); sb.AppendLine("<p>" + h(KPRes.BackupDatabase) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill); CompositeKey ck = pd.MasterKey; if (ck.UserKeyCount > 0) { sb.AppendLine("<br />"); sb.AppendLine("<h3>" + h(KPRes.MasterKey) + "</h3>"); sb.AppendLine("<p>" + h(KPRes.MasterKeyComponents) + "</p>"); sb.AppendLine("<ul>"); foreach (IUserKey k in ck.UserKeys) { KcpPassword p = (k as KcpPassword); KcpKeyFile kf = (k as KcpKeyFile); KcpUserAccount a = (k as KcpUserAccount); KcpCustomKey c = (k as KcpCustomKey); if (p != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.MasterPassword) + ":</strong></p>"); sb.AppendLine(strFill + "</li>"); } else if (kf != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.KeyFile) + ":</strong></p>"); sb.AppendLine(strFillInitEx + ne(h(ltrPath(kf.Path))) + strFillEnd); sb.AppendLine("<p>" + h(KPRes.BackupFile) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill); sb.AppendLine("</li>"); } else if (a != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.WindowsUserAccount) + ":</strong></p>"); sb.Append(strFillInitEx); try { sb.Append(ne(h(ltrPath(Environment.UserDomainName + "\\" + Environment.UserName)))); } catch (Exception) { Debug.Assert(false); sb.Append(ne(string.Empty)); } sb.AppendLine(strFillEnd); sb.AppendLine("<p>" + h(KPRes.WindowsUserAccountBackup) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill + "</li>"); } else if (c != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.KeyProvider) + ":</strong></p>"); sb.AppendLine(strFillInitEx + ne(h(ltrPath(c.Name))) + strFillEnd); sb.AppendLine("</li>"); } else { Debug.Assert(false); sb.AppendLine("<li><p><strong>" + h(KPRes.Unknown) + ".</strong></p></li>"); } } sb.AppendLine("</ul>"); } sb.AppendLine("<br />"); sb.AppendLine("<h3>" + h(KPRes.InstrAndGenInfo) + "</h3>"); sb.AppendLine("<ul class=\"withspc\">"); sb.AppendLine("<li>" + h(KPRes.EmergencySheetInfo) + "</li>"); // sb.AppendLine("<form class=\"scronly\" action=\"#\" onsubmit=\"javascript:window.print();\">"); // sb.AppendLine("<input type=\"submit\" value=\"🖶 " + // h(KPRes.Print) + "\" />"); // sb.AppendLine("</form></li>"); sb.AppendLine("<li>" + h(KPRes.DataLoss) + "</li>"); sb.AppendLine("<li>" + h(KPRes.LatestVersionWeb) + ": <a href=\"" + h(PwDefs.HomepageUrl) + "\" target=\"_blank\">" + h(PwDefs.HomepageUrl) + "</a>.</li>"); sb.AppendLine("</ul>"); }
private static string GenerateHtml(PwDatabase pd, string strName) { StrToStrDelegate h = new StrToStrDelegate(StrUtil.StringToHtml); StrToStrDelegate ne = delegate(string str) { if (string.IsNullOrEmpty(str)) { return(" "); } return(str); }; StringBuilder sb = new StringBuilder(); bool bRtl = Program.Translation.Properties.RightToLeft; sb.AppendLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\""); sb.AppendLine("\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"); sb.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\""); string strLang = Program.Translation.Properties.Iso6391Code; if (string.IsNullOrEmpty(strLang)) { strLang = "en"; } strLang = h(strLang); sb.Append(" lang=\"" + strLang + "\" xml:lang=\"" + strLang + "\""); if (bRtl) { sb.Append(" dir=\"rtl\""); } sb.AppendLine(">"); sb.AppendLine("<head>"); sb.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"); sb.Append("<title>"); sb.Append(h(strName + " - " + KPRes.EmergencySheet)); sb.AppendLine("</title>"); sb.AppendLine("<meta http-equiv=\"expires\" content=\"0\" />"); sb.AppendLine("<meta http-equiv=\"cache-control\" content=\"no-cache\" />"); sb.AppendLine("<meta http-equiv=\"pragma\" content=\"no-cache\" />"); sb.AppendLine("<style type=\"text/css\"><!--"); sb.AppendLine("body, p, div, h1, h2, h3, h4, h5, h6, ol, ul, li, td, th, dd, dt, a {"); sb.AppendLine("\tfont-family: \"Arial\", \"Tahoma\", \"Verdana\", sans-serif;"); sb.AppendLine("\tfont-size: 12pt;"); sb.AppendLine("}"); sb.AppendLine("body, p, div, table {"); sb.AppendLine("\tcolor: #000000;"); sb.AppendLine("\tbackground-color: #FFFFFF;"); sb.AppendLine("}"); sb.AppendLine("p, h3 {"); sb.AppendLine("\tmargin: 0.5em 0em 0.5em 0em;"); sb.AppendLine("}"); sb.AppendLine("ol, ul {"); sb.AppendLine("\tmargin-bottom: 0em;"); sb.AppendLine("}"); sb.AppendLine("h1, h2, h3 {"); sb.AppendLine("\tfont-family: \"Verdana\", \"Arial\", \"Tahoma\", sans-serif;"); sb.AppendLine("}"); sb.AppendLine("h1, h2 {"); sb.AppendLine("\ttext-align: center;"); sb.AppendLine("\tmargin: 0pt 0pt 0pt 0pt;"); sb.AppendLine("}"); sb.AppendLine("h1 {"); sb.AppendLine("\tfont-size: 2em;"); sb.AppendLine("\tpadding: 3pt 0pt 0pt 0pt;"); sb.AppendLine("}"); sb.AppendLine("h2 {"); sb.AppendLine("\tfont-size: 1.5em;"); sb.AppendLine("\tpadding: 1pt 0pt 3pt 0pt;"); sb.AppendLine("}"); sb.AppendLine("h3 {"); sb.AppendLine("\tfont-size: 1.2em;"); // sb.AppendLine("\tpadding: 3pt 3pt 3pt 3pt;"); // sb.AppendLine("\tcolor: #000000;"); // sb.AppendLine("\tbackground-color: #EEEEEE;"); // sb.AppendLine("\tbackground-image: -webkit-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: -moz-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: -ms-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: linear-gradient(to bottom, #E2E2E2, #FAFAFA);"); sb.AppendLine("}"); sb.AppendLine("h4 { font-size: 1em; }"); sb.AppendLine("h5 { font-size: 0.89em; }"); sb.AppendLine("h6 { font-size: 0.6em; }"); sb.AppendLine("a:visited {"); sb.AppendLine("\ttext-decoration: none;"); sb.AppendLine("\tcolor: #0000DD;"); sb.AppendLine("}"); sb.AppendLine("a:active {"); sb.AppendLine("\ttext-decoration: none;"); sb.AppendLine("\tcolor: #6699FF;"); sb.AppendLine("}"); sb.AppendLine("a:link {"); sb.AppendLine("\ttext-decoration: none;"); sb.AppendLine("\tcolor: #0000DD;"); sb.AppendLine("}"); sb.AppendLine("a:hover {"); sb.AppendLine("\ttext-decoration: underline;"); sb.AppendLine("\tcolor: #6699FF;"); sb.AppendLine("}"); sb.AppendLine("img {"); sb.AppendLine("\tborder: 0px none;"); sb.AppendLine("}"); sb.AppendLine(".withspc > li + li {"); sb.AppendLine("\tmargin-top: 0.5em;"); sb.AppendLine("}"); sb.AppendLine("table.docheader {"); sb.AppendLine("\twidth: 100%;"); sb.AppendLine("\tbackground-color: #EEEEEE;"); sb.AppendLine("\tmargin: 0px 0px 0px 0px;"); sb.AppendLine("\tpadding: 0px 0px 0px 0px;"); sb.AppendLine("\tborder: thin solid #808080;"); // border-collapse is incompatible with border-radius // sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\t-webkit-border-radius: 5px;"); sb.AppendLine("\t-moz-border-radius: 5px;"); sb.AppendLine("\tborder-radius: 5px;"); sb.AppendLine("}"); sb.AppendLine("table.docheader tr td {"); sb.AppendLine("\tvertical-align: middle;"); sb.AppendLine("\tpadding: 0px 15px 0px 15px;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline {"); sb.AppendLine("\twidth: 100%;"); sb.AppendLine("\tmargin: 0px 0px 0px 0px;"); sb.AppendLine("\tpadding: 0px 0px 0px 0px;"); sb.AppendLine("\tborder: thin solid #808080;"); sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\tempty-cells: show;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline tr td {"); sb.AppendLine("\tpadding: 4pt 4pt 4pt 4pt;"); sb.AppendLine("\tvertical-align: middle;"); sb.AppendLine("\tword-break: break-all;"); sb.AppendLine("\toverflow-wrap: break-word;"); sb.AppendLine("\tword-wrap: break-word;"); sb.AppendLine("}"); // sb.AppendLine("span.fillinlinesym {"); // sb.AppendLine("\tdisplay: inline-block;"); // sb.AppendLine("\ttransform: scale(1.75, 1.75) translate(-0.5pt, -0.5pt);"); // sb.AppendLine("}"); // sb.AppendLine("@media print {"); // sb.AppendLine(".scronly {"); // sb.AppendLine("\tdisplay: none;"); // sb.AppendLine("}"); // sb.AppendLine("}"); // Add the temporary content identifier sb.AppendLine("." + Program.TempFilesPool.TempContentTag + " {"); sb.AppendLine("\tfont-size: 12pt;"); sb.AppendLine("}"); sb.AppendLine("--></style>"); sb.AppendLine("</head><body>"); ImageArchive ia = new ImageArchive(); ia.Load(Properties.Resources.Images_App_HighRes); sb.AppendLine("<table class=\"docheader\" cellspacing=\"0\" cellpadding=\"0\"><tr>"); sb.AppendLine("<td style=\"text-align: left;\">"); sb.AppendLine("<img src=\"" + GfxUtil.ImageToDataUri(ia.GetForObject( "KeePass")) + "\" width=\"48\" height=\"48\" alt=\"" + h(PwDefs.ShortProductName) + "\" /></td>"); sb.AppendLine("<td style=\"text-align: center;\">"); sb.AppendLine("<h1>" + h(PwDefs.ShortProductName) + "</h1>"); sb.AppendLine("<h2>" + h(KPRes.EmergencySheet) + "</h2>"); sb.AppendLine("</td>"); sb.AppendLine("<td style=\"text-align: right;\">"); sb.AppendLine("<img src=\"" + GfxUtil.ImageToDataUri(ia.GetForObject( "KOrganizer")) + "\" width=\"48\" height=\"48\" alt=\"" + h(KPRes.EmergencySheet) + "\" /></td>"); sb.AppendLine("</tr></table>"); sb.AppendLine("<p style=\"text-align: right;\">" + h( TimeUtil.ToDisplayStringDateOnly(DateTime.Now)) + "</p>"); const string strFillInit = "<table class=\"fillinline\"><tr><td>"; const string strFillEnd = "</td></tr></table>"; string strFillSym = "<img src=\"" + GfxUtil.ImageToDataUri( Properties.Resources.B48x35_WritingHand) + "\" style=\"width: 1.3714em; height: 1em;\" alt=\"✍\" />"; string strFill = strFillInit + ne(string.Empty) + // "</td><td style=\"text-align: right;\"><span class=\"fillinlinesym\">✍</span>" + "</td><td style=\"text-align: right;\">" + strFillSym + strFillEnd; IOConnectionInfo ioc = pd.IOConnectionInfo; sb.AppendLine("<p><strong>" + h(KPRes.DatabaseFile) + ":</strong></p>"); sb.AppendLine(strFillInit + ne(h(ioc.Path)) + strFillEnd); // if(pd.Name.Length > 0) // sb.AppendLine("<p><strong>" + h(KPRes.Name) + ":</strong> " + // h(pd.Name) + "</p>"); // if(pd.Description.Length > 0) // sb.AppendLine("<p><strong>" + h(KPRes.Description) + ":</strong> " + // h(pd.Description)); sb.AppendLine("<p>" + h(KPRes.BackupDatabase) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill); CompositeKey ck = pd.MasterKey; if (ck.UserKeyCount > 0) { sb.AppendLine("<br />"); sb.AppendLine("<h3>" + h(KPRes.MasterKey) + "</h3>"); sb.AppendLine("<p>" + h(KPRes.MasterKeyComponents) + "</p>"); sb.AppendLine("<ul>"); foreach (IUserKey k in ck.UserKeys) { KcpPassword p = (k as KcpPassword); KcpKeyFile kf = (k as KcpKeyFile); KcpUserAccount a = (k as KcpUserAccount); KcpCustomKey c = (k as KcpCustomKey); if (p != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.MasterPassword) + ":</strong></p>"); sb.AppendLine(strFill + "</li>"); } else if (kf != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.KeyFile) + ":</strong></p>"); sb.AppendLine(strFillInit + ne(h(kf.Path)) + strFillEnd); sb.AppendLine("<p>" + h(KPRes.BackupFile) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill); sb.AppendLine("</li>"); } else if (a != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.WindowsUserAccount) + ":</strong></p>"); sb.Append(strFillInit); try { sb.Append(ne(h(Environment.UserDomainName + "\\" + Environment.UserName))); } catch (Exception) { Debug.Assert(false); sb.Append(ne(string.Empty)); } sb.AppendLine(strFillEnd); sb.AppendLine("<p>" + h(KPRes.WindowsUserAccountBackup) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill + "</li>"); } else if (c != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.KeyProvider) + ":</strong></p>"); sb.AppendLine(strFillInit + ne(h(c.Name)) + strFillEnd); sb.AppendLine("</li>"); } else { Debug.Assert(false); sb.AppendLine("<li><p><strong>" + h(KPRes.Unknown) + ".</strong></p></li>"); } } sb.AppendLine("</ul>"); } sb.AppendLine("<br />"); sb.AppendLine("<h3>" + h(KPRes.InstrAndGenInfo) + "</h3>"); sb.AppendLine("<ul class=\"withspc\">"); sb.AppendLine("<li>" + h(KPRes.EmergencySheetInfo) + "</li>"); // sb.AppendLine("<form class=\"scronly\" action=\"#\" onsubmit=\"javascript:window.print();\">"); // sb.AppendLine("<input type=\"submit\" value=\"🖶 " + // h(KPRes.Print) + "\" />"); // sb.AppendLine("</form></li>"); sb.AppendLine("<li>" + h(KPRes.DataLoss) + "</li>"); sb.AppendLine("<li>" + h(KPRes.LatestVersionWeb) + ": <a href=\"" + h(PwDefs.HomepageUrl) + "\" target=\"_blank\">" + h(PwDefs.HomepageUrl) + "</a>.</li>"); sb.AppendLine("</ul>"); sb.AppendLine("</body></html>"); return(sb.ToString()); }
private static string GenerateHtml(PwDatabase pd, string strName) { bool bRtl = Program.Translation.Properties.RightToLeft; string strLogLeft = (bRtl ? "right" : "left"); string strLogRight = (bRtl ? "left" : "right"); GFunc <string, string> h = new GFunc <string, string>(StrUtil.StringToHtml); GFunc <string, string> ne = delegate(string str) { if (string.IsNullOrEmpty(str)) { return(" "); } return(str); }; GFunc <string, string> ltrPath = delegate(string str) { return(bRtl ? StrUtil.EnsureLtrPath(str) : str); }; StringBuilder sb = new StringBuilder(); sb.AppendLine("<!DOCTYPE html>"); sb.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\""); string strLang = Program.Translation.Properties.Iso6391Code; if (string.IsNullOrEmpty(strLang)) { strLang = "en"; } strLang = h(strLang); sb.Append(" xml:lang=\"" + strLang + "\" lang=\"" + strLang + "\""); if (bRtl) { sb.Append(" dir=\"rtl\""); } sb.AppendLine(">"); sb.AppendLine("<head>"); sb.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"); sb.AppendLine("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />"); sb.AppendLine("<meta http-equiv=\"expires\" content=\"0\" />"); sb.AppendLine("<meta http-equiv=\"cache-control\" content=\"no-cache\" />"); sb.AppendLine("<meta http-equiv=\"pragma\" content=\"no-cache\" />"); sb.Append("<title>"); sb.Append(h(strName + " - " + KPRes.EmergencySheet)); sb.AppendLine("</title>"); sb.AppendLine("<style type=\"text/css\">"); sb.AppendLine("/* <![CDATA[ */"); string strFont = "\"Arial\", \"Tahoma\", \"Verdana\", sans-serif;"; // https://sourceforge.net/p/keepass/discussion/329220/thread/f98dece5/ if (Program.Translation.IsFor("fa")) { strFont = "\"Tahoma\", \"Arial\", \"Verdana\", sans-serif;"; } sb.AppendLine("body {"); sb.AppendLine("\tcolor: #000000;"); sb.AppendLine("\tbackground-color: #FFFFFF;"); sb.AppendLine("\tfont-family: " + strFont); sb.AppendLine("\tfont-size: 12pt;"); sb.AppendLine("}"); sb.AppendLine("h3, p {"); sb.AppendLine("\tmargin: 0.5em 0em 0.5em 0em;"); sb.AppendLine("}"); sb.AppendLine("ol, ul {"); sb.AppendLine("\tmargin-bottom: 0em;"); sb.AppendLine("}"); sb.AppendLine("h1, h2, h3 {"); sb.AppendLine("\tfont-family: \"Verdana\", \"Arial\", \"Tahoma\", sans-serif;"); sb.AppendLine("}"); sb.AppendLine("h1, h2 {"); sb.AppendLine("\tmargin: 0pt 0pt 0pt 0pt;"); sb.AppendLine("\ttext-align: center;"); sb.AppendLine("}"); sb.AppendLine("h1 {"); sb.AppendLine("\tpadding: 3pt 0pt 0pt 0pt;"); sb.AppendLine("}"); sb.AppendLine("h2 {"); sb.AppendLine("\tpadding: 1pt 0pt 3pt 0pt;"); sb.AppendLine("}"); // sb.AppendLine("h3 {"); // sb.AppendLine("\tpadding: 3pt 3pt 3pt 3pt;"); // sb.AppendLine("\tcolor: #000000;"); // sb.AppendLine("\tbackground-color: #EEEEEE;"); // sb.AppendLine("\tbackground-image: -webkit-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: -moz-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: -ms-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: linear-gradient(to bottom, #E2E2E2, #FAFAFA);"); // sb.AppendLine("}"); sb.AppendLine("a {"); sb.AppendLine("\tcolor: #0000DD;"); sb.AppendLine("\ttext-decoration: none;"); sb.AppendLine("}"); sb.AppendLine("a:hover, a:active {"); sb.AppendLine("\tcolor: #6699FF;"); sb.AppendLine("\ttext-decoration: underline;"); sb.AppendLine("}"); sb.AppendLine("img {"); sb.AppendLine("\tborder: 0px none;"); sb.AppendLine("}"); sb.AppendLine(".withspc > li + li {"); sb.AppendLine("\tmargin-top: 0.5em;"); sb.AppendLine("}"); sb.AppendLine("table.docheader {"); sb.AppendLine("\twidth: 100%;"); sb.AppendLine("\tbackground-color: #EEEEEE;"); sb.AppendLine("\tmargin: 0px 0px 0px 0px;"); sb.AppendLine("\tpadding: 0px 0px 0px 0px;"); sb.AppendLine("\tborder: thin solid #808080;"); // border-collapse is incompatible with border-radius // sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\t-webkit-border-radius: 5px;"); sb.AppendLine("\t-moz-border-radius: 5px;"); sb.AppendLine("\tborder-radius: 5px;"); sb.AppendLine("}"); sb.AppendLine("table.docheader tr td {"); sb.AppendLine("\tborder: 0px none;"); sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\tpadding: 0px 15px 0px 15px;"); sb.AppendLine("\tvertical-align: middle;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline {"); sb.AppendLine("\twidth: 100%;"); sb.AppendLine("\tmargin: 0px 0px 0px 0px;"); sb.AppendLine("\tpadding: 0px 0px 0px 0px;"); sb.AppendLine("\tborder: thin solid #808080;"); sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\ttable-layout: fixed;"); sb.AppendLine("\tempty-cells: show;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline tr td {"); sb.AppendLine("\tpadding: 4pt 4pt 4pt 4pt;"); sb.AppendLine("\tvertical-align: middle;"); sb.AppendLine("\tword-break: break-all;"); sb.AppendLine("\toverflow-wrap: break-word;"); sb.AppendLine("\tword-wrap: break-word;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline tr td img {"); sb.AppendLine("\tdisplay: block;"); // Inline results in additional space at the bottom sb.AppendLine("\tmargin: 0px " + (bRtl ? "auto 0px 0px;" : "0px 0px auto;")); sb.AppendLine("}"); // sb.AppendLine("span.fillinlinesym {"); // sb.AppendLine("\tdisplay: inline-block;"); // sb.AppendLine("\ttransform: scale(1.75, 1.75) translate(-0.5pt, -0.5pt);"); // sb.AppendLine("}"); // sb.AppendLine("@media print {"); // sb.AppendLine(".scronly {"); // sb.AppendLine("\tdisplay: none;"); // sb.AppendLine("}"); // sb.AppendLine("}"); // Add the temporary content identifier // (always, as the sheet should be printed, not saved) sb.AppendLine("." + Program.TempFilesPool.TempContentTag + " {"); sb.AppendLine("\tfont-size: 12pt;"); sb.AppendLine("}"); sb.AppendLine("/* ]]> */"); sb.AppendLine("</style>"); sb.AppendLine("</head><body>"); ImageArchive ia = new ImageArchive(); ia.Load(Properties.Resources.Images_App_HighRes); sb.AppendLine("<table class=\"docheader\"><tr>"); sb.AppendLine("<td style=\"text-align: " + strLogLeft + ";\">"); sb.AppendLine("<img src=\"" + GfxUtil.ImageToDataUri(ia.GetForObject( "KeePass")) + "\" width=\"48\" height=\"48\" alt=\"" + h(PwDefs.ShortProductName) + "\" /></td>"); sb.AppendLine("<td style=\"text-align: center;\">"); sb.AppendLine("<h1>" + h(PwDefs.ShortProductName) + "</h1>"); sb.AppendLine("<h2>" + h(KPRes.EmergencySheet) + "</h2>"); sb.AppendLine("</td>"); sb.AppendLine("<td style=\"text-align: " + strLogRight + ";\">"); sb.AppendLine("<img src=\"" + GfxUtil.ImageToDataUri(ia.GetForObject( "KOrganizer")) + "\" width=\"48\" height=\"48\" alt=\"" + h(KPRes.EmergencySheet) + "\" /></td>"); sb.AppendLine("</tr></table>"); sb.AppendLine("<p style=\"text-align: " + strLogRight + ";\">" + h(TimeUtil.ToDisplayStringDateOnly(DateTime.Now)) + "</p>"); const string strFillInit = "<table class=\"fillinline\"><tr><td>"; const string strFillInitLtr = "<table class=\"fillinline\"><tr><td dir=\"ltr\">"; const string strFillEnd = "</td></tr></table>"; string strFillSym = "<img src=\"" + GfxUtil.ImageToDataUri( Properties.Resources.B48x35_WritingHand) + "\" style=\"width: 1.3714em; height: 1em;" + (bRtl ? " transform: scaleX(-1);" : string.Empty) + "\" alt=\"✍\" />"; string strFill = strFillInit + ne(string.Empty) + // "</td><td style=\"text-align: right;\"><span class=\"fillinlinesym\">✍</span>" + // "</td><td style=\"text-align: " + strLogRight + ";\">" + "</td><td>" + strFillSym + strFillEnd; string strFillInitEx = (bRtl ? strFillInitLtr : strFillInit); IOConnectionInfo ioc = pd.IOConnectionInfo; sb.AppendLine("<p><strong>" + h(KPRes.DatabaseFile) + ":</strong></p>"); sb.AppendLine(strFillInitEx + ne(h(ltrPath(ioc.Path))) + strFillEnd); // if(pd.Name.Length > 0) // sb.AppendLine("<p><strong>" + h(KPRes.Name) + ":</strong> " + // h(pd.Name) + "</p>"); // if(pd.Description.Length > 0) // sb.AppendLine("<p><strong>" + h(KPRes.Description) + ":</strong> " + // h(pd.Description)); sb.AppendLine("<p>" + h(KPRes.BackupDatabase) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill); CompositeKey ck = pd.MasterKey; if (ck.UserKeyCount > 0) { sb.AppendLine("<br />"); sb.AppendLine("<h3>" + h(KPRes.MasterKey) + "</h3>"); sb.AppendLine("<p>" + h(KPRes.MasterKeyComponents) + "</p>"); sb.AppendLine("<ul>"); foreach (IUserKey k in ck.UserKeys) { KcpPassword p = (k as KcpPassword); KcpKeyFile kf = (k as KcpKeyFile); KcpUserAccount a = (k as KcpUserAccount); KcpCustomKey c = (k as KcpCustomKey); if (p != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.MasterPassword) + ":</strong></p>"); sb.AppendLine(strFill + "</li>"); } else if (kf != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.KeyFile) + ":</strong></p>"); sb.AppendLine(strFillInitEx + ne(h(ltrPath(kf.Path))) + strFillEnd); sb.AppendLine("<p>" + h(KPRes.BackupFile) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill); sb.AppendLine("</li>"); } else if (a != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.WindowsUserAccount) + ":</strong></p>"); sb.Append(strFillInitEx); try { sb.Append(ne(h(ltrPath(Environment.UserDomainName + "\\" + Environment.UserName)))); } catch (Exception) { Debug.Assert(false); sb.Append(ne(string.Empty)); } sb.AppendLine(strFillEnd); sb.AppendLine("<p>" + h(KPRes.WindowsUserAccountBackup) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill + "</li>"); } else if (c != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.KeyProvider) + ":</strong></p>"); sb.AppendLine(strFillInitEx + ne(h(ltrPath(c.Name))) + strFillEnd); sb.AppendLine("</li>"); } else { Debug.Assert(false); sb.AppendLine("<li><p><strong>" + h(KPRes.Unknown) + ".</strong></p></li>"); } } sb.AppendLine("</ul>"); } sb.AppendLine("<br />"); sb.AppendLine("<h3>" + h(KPRes.InstrAndGenInfo) + "</h3>"); sb.AppendLine("<ul class=\"withspc\">"); sb.AppendLine("<li>" + h(KPRes.EmergencySheetInfo) + "</li>"); // sb.AppendLine("<form class=\"scronly\" action=\"#\" onsubmit=\"javascript:window.print();\">"); // sb.AppendLine("<input type=\"submit\" value=\"🖶 " + // h(KPRes.Print) + "\" />"); // sb.AppendLine("</form></li>"); sb.AppendLine("<li>" + h(KPRes.DataLoss) + "</li>"); sb.AppendLine("<li>" + h(KPRes.LatestVersionWeb) + ": <a href=\"" + h(PwDefs.HomepageUrl) + "\" target=\"_blank\">" + h(PwDefs.HomepageUrl) + "</a>.</li>"); sb.AppendLine("</ul>"); sb.AppendLine("</body></html>"); string strDoc = sb.ToString(); #if DEBUG XmlUtilEx.ValidateXml(strDoc, true); #endif return(strDoc); }