我想首先在 Umbraco 的内容编辑器中加密一些节点。下面的代码是我用于加密的代码。我为此使用 MachineKey.Protect。 try { MailMessage message1 = new MailMessage(); MailMessage message2 = new MailMessage(); SmtpClient client = new SmtpClient(); string AfsenderEmail = model.Email; string AfsenderNavn = model.Name; string toAddress = Umbraco.Content(rootNode.Id).mailDerSendesTil; message1.From = new MailAddress(toAddress); message2.From = new MailAddress(toAddress); message1.Subject = $"{Umbraco.Content(rootNode.Id).overskriftPaaDenMailViFaar}"; message1.Subject = message1.Subject.Replace("AfsenderEmail", AfsenderEmail); message1.Subject = message1.Subject.Replace("AfsenderNavn", AfsenderNavn); message1.Body = $"{Umbraco.Content(rootNode.Id).beskedViFaarNaarBeskedenSendes}"; message1.Body = message1.Body.Replace("AfsenderEmail", AfsenderEmail); message1.Body = message1.Body.Replace("AfsenderNavn", AfsenderNavn); message1.To.Add(new MailAddress(toAddress)); client.Send(message1); message2.Subject = $"{Umbraco.Content(rootNode.Id).overskriftPaaMeddelelsenAfsenderenFaar}"; message2.Subject = message2.Subject.Replace("AfsenderEmail", AfsenderEmail); message2.Subject = message2.Subject.Replace("AfsenderNavn", AfsenderNavn); message2.Body = $"{Umbraco.Content(rootNode.Id).beskedAfsenderenFaarNaarBeskedenSendes}"; message2.Body = message2.Body.Replace("AfsenderEmail", AfsenderEmail); message2.Body = message2.Body.Replace("AfsenderNavn", AfsenderNavn); message2.To.Add(new MailAddress(AfsenderEmail)); client.Send(message2); }这是我尝试再次解密我的代码的地方。当我调用 MachineKey.Unprotect(nameDecrypted) 并且找不到我的错误时,它会引发异常
1 回答
红颜莎娜
TA贡献1842条经验 获得超12个赞
我找到了解决方案。我没有使用 Encoding.ASCII.GetString(),而是使用了 Convert.FromBase64String()。
- 1 回答
- 0 关注
- 217 浏览
添加回答
举报
0/150
提交
取消