vendredi 8 mai 2015

How to hide sensitive information with random numbers in C# with a function

I am looking for a function that takes in a line of customer info like this sample:

125478744|John|Smith|1234567890123456|50.00|Dinner

Then I will then split that info and place it in a string array with this function:

private static string[] ScrubData(string text)
    {
        //here is where the string is broken apart
        String[] customerInfo = text.Split('|');
        return customerInfo;
    }

Then I need another function that will do the following:

Replace the first column of numbers which would be social security numbers with nine random numbers between 1 and 9.

Then the third column which is the customer's last name, I need to generate random letters for each character of the last name and replace them.

In column 4, which would be account numbers, I need to replace all the numbers except for the last 4 with 'X'.

In column 5, which is the amount, I need check to see if the amount is greater than 100. If it is, I need to create a new column at the end of the line of info that says yes or no if the amount is greater than 100.

I will be using the following random number generators and random character generator functions:

public static char GetRandomLetter()
{
    string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    Random rand = new Random();
    int num = rand.Next(0, chars.Length -1);
    return chars[num];
}

public static int GetRandomNumber()
{
    Random rnd = new Random();
    int ranNum = rnd.Next(10);//creates random number between 0 and 9
    return ranNum;
}

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire