473,695 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to encrypt a string and store it in aN XML File.

I store a users SMTP UserName and Password in a settings class, which is
serialized to an XML Settings File.

I need to encrypt the password string in some manner. Does anyone have any
ideas how to do that and still store it in the XML File?
I was thinking of putting the Encryption/Decryption code in the Get/Set
methods of the SMTPPassword Property.

Sample Code:

Public Sub Persist()
'// Save the Settings object to XML Files
Dim settingsPath As String =
IO.Path.Combine (Application.Us erAppDataPath, "settings.x ml")
Dim myXMLSerializer As Xml.Serializati on.XmlSerialize r
Dim settingsFile As IO.StreamWriter

'//Save the settings class
myXMLSerializer = New
Xml.Serializati on.XmlSerialize r(GetType(Setti ngs))
settingsFile = New IO.StreamWriter (settingsPath)
myXMLSerializer .Serialize(sett ingsFile, appSettings)
settingsFile.Cl ose()
End Sub

<Serializable() > Public Class Settings
Dim m_SMTPLoginName as String
Dim m_SMTPPassword as String
Public Property SMTPLoginName() as String
Get
Return m_SMTPLoginName
End Get
Set(ByVal Value As String)
m_SMTPLoginName = Value
End Set
End Property
Public Property SMTPPassword() as String
Get
Return m_SMTPPassword
End Get
Set(ByVal Value As String)
m_SMTPPassword = Value
End Set
End Property
End Class
Nov 21 '05 #1
1 2039

"Kevin Hodgson" <ke***@caseware .com> wrote in message
news:uf******** ******@TK2MSFTN GP10.phx.gbl...
I need to encrypt the password string in some manner. Does anyone have
any
ideas how to do that and still store it in the XML File?


After you run it through your encryption routine of choice (a two-way
routine, of course), just base-64 encode the results (see the System.Text
namespace for the Encoding class). Then you'll have normal text that you can
stick in the XML file.
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2936
by: Allan Bruce | last post by:
I want to load config from a file. I know how to load in numbers using an ifstream, but I cant get it to load a string. Can somebody tell me how to load a string from file? Here is my code: int mNumServers; short *mPorts; std::string *mServers; std::string *mPaths;
9
16970
by: Sharon | last post by:
hi, I want to extract a string from a file, if the file is like this: 1 This is the string 2 3 4 how could I extract the string, starting from the 10th position (i.e. "T") and extract 35 characters (including "T") from a file and then go to next line?
7
6920
by: Dan H. | last post by:
Hello, What is the equivalent "string resource file" in c#? And, is there a way to create a beep in C#? Thanks, Dan
2
3797
by: Daniel | last post by:
Is there any way for System.IO.StreamWriter Write method to write out part of the string to file. such as if the machine is shut down half way through? or does the file not actually exist until the entire write is completed successfully.
1
1305
by: Timothy Wang | last post by:
Hi everyone : Is there anybody know how to use a string store in a variable as command ? Like : str1='test...' str2='...test' str3='left(str1, 5) & Right((str2,3 ) ' How do we get 'test.est' from str3 in runtime.
0
4759
by: lima01 | last post by:
Hi there, I need to read key store file to get private key generated by Java's KeyTools from PHP. But seams like the keystore file is not in standard format that PHP can use. I need to do so because I created a WebSevice with Java/Tomcat. Need to create secured connection between PHP client and the Java server. Anyway has similiar experience to share?
15
3649
by: Gan Quan | last post by:
I'm writing a c++ program that has many (100+) threads read/write files simultaneously. It works well if not considering the efficiency. The file i/o seems to be the bottleneck. This is my code to read from and write to files: #include <fstream> #include <sstream> #include <string>
0
1713
by: divy | last post by:
Hi, I am working with Filenet. I have all the below specified WSDL files The elements and types defined in the CEWS schema are assigned to the following namespaces: Common WSDL: http://www.filenet.com/ns/fnce/2004/06/ws/wsdl Common schema: http://www.filenet.com/ns/fnce/2004/06/ws/schema SOAP WSDL: http://www.filenet.com/ns/fnce/2004/06/ws/SOAP/wsdl DIME WSDL: http://www.filenet.com/ns/fnce/2004/06/ws/DIME/wsdl DIME...
2
2164
by: =?Utf-8?B?S3VtYXI=?= | last post by:
I am using granados telnet client for connecting to the telnet and get the data from it. Every thing appears to be going smooth. But for some reason when I try to write the byte data to a string or streamwriter, it looses the final packet. Strangely, If I output the datapackets to a console from the telnet server, it perfectly gets all the output packets. the code snippet is below: StreamWriter sw = new StreamWriter("c:\\output.txt",...
2
3975
by: mahmoodn | last post by:
I want to pass a string as file name to a ifstream object, but I can't. char cnt_string = ""; string f = "ss_"; int cnt = 1; string seq = itoa(cnt, cnt_string, 10); string file = f+seq+".txt"; ifstream fin( file ); The error at last line is:
0
8565
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9113
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8977
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6488
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4339
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2997
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1971
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.