Xamarin.Forms – Obfuscate Bankcard Number

 

namespace Account.UI.Converters
{
    public class CardNumberObfuscatorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var cardNumber =  value as string;
            var numberSet =   cardNumber.Split(' ');
            var last4Digits = numberSet[numberSet.Length - 1];
            return $"XXXX XXXX XXXX {last4Digits}";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}

ObfusatedCardNumbers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: