Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Un-Encrypting Fields to use on a report

Questions related to nuBuilder Forte Reports and the Report Builder.
Post Reply
icoso
Posts: 181
Joined: Sun Feb 07, 2021 11:09 pm
Been thanked: 1 time

Un-Encrypting Fields to use on a report

Unread post by icoso »

I have a field in my table that I stored in an encrypted format. (cust_SSN). I need to un-encrypt this field to be able to print it on the report. Actually I need to just print the last 4 of the SSN on this report.

How do I do this?

1. Im assuming I would use a stored procedure to run from the report (instead of linking it to an stored SQL) I would link the report to a stored procedure such as:

Procedure: GetCustSSN

Code: Select all

]$s = "
SELECT TaxCustomers.*, CONCAT(cust_lastname, ', ', cust_firstname) AS full_name,  FROM TaxCustomers WHERE TaxCustomers.tax_billdate BETWEEN '#RPT_sdate#' AND '#RPT_edate#';
";
nuRunQuery("CREATE TABLE #TABLE_ID# $s");
This would create a temporary table that the report would run against, right?

2. As part of the stored procedure, how then can I run my un-encrypt function against the temporary table? and update/change the cust_SSN field? I can put my un-encrypt function in another stored procedure or load it from a file. The function is:
unencryptSSN($encryptedSSN) I currenlty use this to un-encrypt the SSN when I retrieve the records in a search form and display it on the edit form. The field is already in memory at that point. I'm not sure how to do it for reports?

3. Im assuming that my code would do something like this:
1. for each record in my temporary table, get the cust_SSN, run the function $unecryptedSSN=unencryptSSN(cust_SSN), extract the last4 of the $unecryptedSSN using substr(), then update the temporary table with the $last4SSN, Im assuming that I should change my SQL statement above to create a new field (last4ssn) like this:

SELECT TaxCustomers.*, CONCAT(cust_lastname, ', ', cust_firstname) AS full_name, 9999 as last4SSN , FROM TaxCustomers WHERE TaxCustomers.tax_billdate BETWEEN '#RPT_sdate#' AND '#RPT_edate#';

How would I :

1. Write the for loop or while loop to get each record from the temporary table and assign the encrypted cust_SSN field to a variable?
2. Call my unencryptSSN(cust_SSN) function? to unecrypt the SSN and return it to a variable?
3. Write the UPDATE statement to put it back in the temporary table in the last4SSN field?
4. delete this temporary table AFTER the report has run?
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Un-Encrypting Fields to use on a report

Unread post by kev1n »

Is this the same question as here ? https://forums.nubuilder.cloud/viewtopic.php?f=20&t=10866
If yes, I can delete this duplicate post.
icoso
Posts: 181
Joined: Sun Feb 07, 2021 11:09 pm
Been thanked: 1 time

Re: Un-Encrypting Fields to use on a report

Unread post by icoso »

YEs, seems like not many contribute to the Reports thread.
Post Reply