Perhaps you should store it in its own class
public class Person
{
public string firstName { get; set; }
public SocialSecurityNumber SSN { get; set; }
}
public class SocialSecurityNumber
{
public string SSN { get; set; }
}
Perhaps the class could have its own decrypt method as well.
public class SocialSecurityNumber
{
public string SSN { get; set; }
public string Decrypt()
{
//TODO: Decrypt SSN
return decrypted ssn
}
}
Now in your controller
[HttpPost]
public ActionResult PostedPerson (Person person)
{
string PersonName = person.firstName;
string SocialSecurityNumber = person.SSN.SSN;//or person.SSN.Decrypt();
//TODO: decrypt SocialSecurity number
}
In the case where you are using FormCollection for model binding, then you would have to set some sort of flag or use an abstraction to mark that the field was encrypted
public class Person
{
public string firstName { get; set; }
public SocialSecurityNumber SSN { get; set; }
}
public class SocialSecurityNumber
{
public string SSN { get; set; }
public string Encrypted { get; set; }//set this to "EncryptedTrue" or something
//similar in order to handle it in the post
}
And then with your form collection
[HttpPost]
public ActionResult PostedPerson (FormCollection fc)
{
for( var val in fc )
{
if( val is InnerList ){
{
if( val.Contains("EncryptedTrue") )
{
//then val.SSN would be an encryped social security number
}
}
}
}