Solved

ASP.Net/C# - I want to replace everything but the last 4 characters of a string to "*".

Posted on 2008-06-23
6
641 Views
Last Modified: 2013-12-16
Hello all.  I need to take a value such as SSN and replace all the values of the string other than the last 4 numbers.  For example, 111111111 to *****1111.  Then I need to also keep the actual value though for an update.  Any ideas?
0
Comment
Question by:sbornstein2
  • 3
  • 2
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21854141
Are you wanting to change the value for display?
0
 

Author Comment

by:sbornstein2
ID: 21856727
Learned one that is correct I want to change the value of the SSN where it shows just the last 4 digits but then I do need to still have the actual value itself to store on an update.  The page is SSL but they want this.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21856756
How are you displaying the SSN on the page?
0
 

Author Comment

by:sbornstein2
ID: 21860197
right now it comes back in free text via a web service call.  I need to take that value and mask it and then display it.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 21861570
Do you want to do something like this?

            string ssn = "123-45-6789";

            this.txtSSN.Text = new string('*', ssn.Length - 4) + ssn.Substring(ssn.Length - 4);
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now