<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Simple helper class that performs base64 encoding / decoding.</Title>
      <Shortcut>Simplehelperclassthatperformsbase64encoding/decoding.</Shortcut>
      <Description>Simple helper class that performs base64 encoding / decoding. [C#]</Description>
      <Author>Robert Wagner</Author>
      <HelpUrl>/PreviewSnippet.aspx?SnippetID=8f2fcb02-40d7-49b9-8b15-406491171afd</HelpUrl>
      <SnippetTypes>
        <SnippetType>SurroundsWith</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="csharp"><![CDATA[/*
	Used to store passwords in config file.
*/

using System;
using System.Text;

namespace SmartClient
{
	/// <summary>
	/// Encrypt / decrypt string using base64.
	/// </summary>
	public class SimpleEncrypt
	{
		private SimpleEncrypt()
		{
		}
		
		/// <summary>
		/// Return base64 version of string.
		/// </summary>
		public static string Encrypt(string text)
		{
			try
			{
				byte[] bytes = Encoding.ASCII.GetBytes(text);
				return Convert.ToBase64String(bytes, 0, bytes.Length);
			}
			catch (Exception ex)
			{	
				System.Diagnostics.Debug.WriteLine(ex.Message);
				return String.Empty;
			}
		}

		/// <summary>
		/// Return string version of base64 string.
		/// </summary>
		public static string Decrypt(string text)
		{
			try
			{
				byte[] bytes = Convert.FromBase64String(text);
				return Encoding.ASCII.GetString(bytes, 0, bytes.Length);
			}
			catch (Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(ex.Message);
				return String.Empty;
			}
		}
	}
}
]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>