Solved

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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.…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

11 Experts available now in Live!

Get 1:1 Help Now