I don't know what should I use. I have 3 classes. PasswordService
, SettingsService
, FileService
. These classes each contain about 2 methods. The methods are being used in more assemblies. Now I'm using it as a singleton. But I'm not sure if I should. I think a static class would be enough.
What do you think?
CODE:
public class PasswordService
{
private PasswordService(){}
private static PasswordService _instance;
public static PasswordService Instance
{
get { return _instance ?? (_instance = new PasswordService()); }
}
public byte[] EncryptPassword(string password)
{
var protectedPass = Encoding.UTF8.GetBytes(password);
return ProtectedData.Protect(protectedPass, null);
}
public string DecryptPassword(byte[] encryptedPassword)
{
var unprotectedPass = ProtectedData.Unprotect(encryptedPassword, null);
return Encoding.UTF8.GetString(unprotectedPass, 0, unprotectedPass.Length);
}
}