61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace CrossProduct.Core
|
|
{
|
|
/// <summary>
|
|
/// Wrapper functions around our CrossProducts Encrypt Functionallity
|
|
/// </summary>
|
|
public static class Encryption
|
|
{
|
|
/// <summary>
|
|
/// Encrypt Text
|
|
/// </summary>
|
|
/// <param name="Text">Text To Encrypt</param>
|
|
/// <returns>Encrypted Text or String.Empty if Error Occured</returns>
|
|
public static string EncryptText(string Text)
|
|
{
|
|
try
|
|
{
|
|
PerSeCryptography crypto = new PerSeCryptography();
|
|
string EncryptedText = crypto.EncryptText(Text);
|
|
return EncryptedText;
|
|
}
|
|
catch (Exception) { /* ignore */ }
|
|
return string.Empty;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Encrypt Text for use as a Command-Line Parameter - avoids "
|
|
/// </summary>
|
|
/// <param name="Text">Text To Encrypt</param>
|
|
public static string EncryptTextParameter(string Text)
|
|
{
|
|
string EncryptedText;
|
|
// Keep calling Encrypt Text until it productes a string without a double quote
|
|
do { EncryptedText = EncryptText(Text); } while (EncryptedText.IndexOf('\"') != -1);
|
|
return EncryptedText;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Decrypt Text
|
|
/// </summary>
|
|
/// <param name="Text">Text To Decrypt</param>
|
|
/// <returns>Decrypted Text or String.Empty if Error Occured</returns>
|
|
public static string DecryptText(string Text)
|
|
{
|
|
try
|
|
{
|
|
|
|
PerSeCryptography crypto = new PerSeCryptography();
|
|
string EncryptedText = crypto.DecryptText(Text);
|
|
return EncryptedText;
|
|
}
|
|
catch (Exception) { /* ignore */ }
|
|
return string.Empty;
|
|
}
|
|
}
|
|
}
|