32
of 76
TEP , The Engineering Projects , Image

syedzainnasir

TEP , The Engineering Projects , Rating 7.5 7.5 / 10
TEP , The Engineering Projects , Icon Level: Moderator
TEP , The Engineering Projects , Icon Joined: 20 Mar 2022
TEP , The Engineering Projects , Icon Last Active: 2:21 PM
TEP , The Engineering Projects , Icon Location: TEP , The Engineering Projects , Flag
TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon
Decrypt XML file error: Padding is invalid and cannot be removed
TEP , The Engineering Projects , Calender Question: 07-Mar-2017
TEP , The Engineering Projects , Category In: Microsoft Visual Studio Projects
I encrypt an XML file and save it to the original file.
I then open the file and try to decrypt it, and get the error "Padding is invalid and cannot be removed".
I think this is because during encryption, I execute [code]key = New RijndaelManaged()[/code] And, during decryption, I also execute [code]key = New RijndaelManaged()[/code] How can I save the key from the encryption ?
Thank you.

This is the code to encrypt and save the XML file: [code]Imports System.Xml Imports System.Security.Cryptography Imports System.Security.Cryptography.Xml Dim key As RijndaelManaged = Nothing ' Create a new Rijndael key. key = New RijndaelManaged() ' Load an XML document. Dim xmlDoc As New XmlDocument() xmlDoc.PreserveWhitespace = True xmlDoc.Load("myXMLFile.XML") Encrypt(xmlDoc, "myElement1", key) Encrypt(xmlDoc, "myElement2", key) xmlDoc.Save("myXMLFile.XML")[/code] This is the code to decrypt the XML file: [code]Imports System.Xml Imports System.Security.Cryptography Imports System.Security.Cryptography.Xml Dim key As RijndaelManaged = Nothing key = New RijndaelManaged() Dim xmlDoc As New XmlDocument() xmlDoc.PreserveWhitespace = True xmlDoc.Load("myXMLFile.XML") Decrypt(xmlDoc, key)[/code]
TEP , The Engineering Projects , Icon Answer: 0 TEP , The Engineering Projects , Icon Views: 150 TEP , The Engineering Projects , Icon Followers: 85
Small Bio
TEP , The Engineering Projects , Tags
PLC
Robot
STM32
Arduino
AI
ESP32
Ladder Logic
PLC Projects
Programming
Communicates STM32
PLC Projects
Communicates PLC
Font Style
Alignment
Indenting and Lists
Insert Media
Insert Items

Want to leave an answer!

Word Count :0 Draft Saved at 12:42 am.