Solved

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

Posted on 2008-06-23
6
647 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

789 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