[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2008-06-23
6
Medium Priority
?
662 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
5 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 1000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Integration Management Part 2
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

872 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