Using system;
Using system. Collections. Generic;
Using system. text;
Namespace prjw
{
/// <Summary>
/// A simple base64-based encryption and Encryption Class... it is mainly used to store passwords in local configuration files...
/// </Summary>
Class simple
{
/// <Summary>
/// Encrypted string, returns a 64-bit encoded string
/// </Summary>
/// <Param name = "text"> </param>
/// <Returns> </returns>
Public static string encrypt (string text)
{
Try
{
// Convert plaintext to an ASCII byte array
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;
}
}
Public static string decrypt (string text)
{
Try
{
// Convert a 64-bit integer string to an 8-bit unsigned integer Array
Byte [] bytes = convert. frombase64string (text );
// Return the decoded string
Return encoding. ASCII. getstring (bytes, 0, bytes. Length );
}
Catch (exception ex)
{
System. Diagnostics. Debug. writeline (ex. Message );
Return string. empty;
}
}
}
}