Я хочу зашифровать текстовое содержимое документа HTML без изменения его макета.Содержимое хранится в виде пар тегов, например: text_to_get .Моя идея - использовать Regex для получения (1) и замены каждой текстовой части зашифрованным текстом (2).Я завершаю шаг (1), но на шаге (2) возникают проблемы.Вот код, над которым я работаю:
private string encryptSpanContent(string text, string passPhrase, string salt, string hash, int iteration, string initialVector, int keySize)
{
string resultText = text;
string pattern = "<span style=(?<style>.*?)>(?<content>.*?)</span>";
Regex regex = new Regex(pattern);
MatchCollection matches = regex.Matches(resultText);
foreach (Match match in matches)
{
string replaceWith = "<span style=" + match.Groups["style"] + ">" + AESEncryption.Encrypt(match.Groups["content"].Value, passPhrase, salt, hash, iteration, initialVector, keySize) + "</span>";
resultText = regex.Replace(resultText, replaceWith);
}
return resultText;
}
Это неправильная строка (заменяет все тексты последним значением replaceWith)?
resultText = regex.Replace(resultText, replaceWith);
Может кто-нибудь помочь?мне это исправить?