Search This Blog
Sunday, May 20, 2012
System Thinking World Journal
Friday, February 3, 2012
Credit Card Parsing Algorithm for Unix
1) Get a dump of database table (or important columns) to your unix box.
2) Write a "ccengine" parsing script based on Lugn's algorithm.
3) Dump the rows with credit card numbers.
4) Hide the CC# with regexp .
5) Upload back to the database.
Here is a credit card engine script in SED to help developers parse through credit card numbers in Unix which is needed prior to implementing Luhn's algorithm .
Create a file "ccengine.sed" with following content
s/[./\-#$%^&@_*!\ ]4[0-9]\{3\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$%^&@_*!\ ]*[0-9]\{3\}/\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*/g
s/[./\-#$%^&@_*!\ ]5[1-5][0-9]\{2\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$%^&@_*!\ ]*[0-9]\{3\}/\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*\*/g
s/[./\-#$%^&@_*!\ ]6011[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$%^&@_*!\ ]*[0-9]\{3\}/\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*/g
s/[./\-#$%^&@_*!\ ]4[0-9]\{3\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}/\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*\*/g
s/[./\-#$%^&@_*!\ ]5[1-5][0-9]\{2\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$%^&@_*!\ ]*[0-9]\{4\}[./\-#$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*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*\*/g
s/6011[- ]*[0-9]\{4\}[- ]*[0-9]\{4\}[- ]*[0-9]\{4\}/\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*\*/g
s/3[47][0-9]\{13\}/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/g
s/30[0-5][0-9][- ]*[0-9]\{4\}[- ]*[0-9]\{4\}[- ]*[0-9]\{2\}/\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*\*/g
s/36[0-9]\{2\}[- ]*[0-9]\{4\}[- ]*[0-9]\{4\}[- ]*[0-9]\{2\}/\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*\*/g
s/38[0-9]\{2\}[- ]*[0-9]\{4\}[- ]*[0-9]\{4\}[- ]*[0-9]\{2\}/\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*\*/g
s/[^0-9]4[0-9]\{3\}[- ]*[0-9]\{4\}[- ]*[0-9]\{4\}[- ]*[0-9]/\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*\*/g
s/[#- ]4[0-9]\{3\}[- ]*[0-9]\{4\}[- ]*[0-9]\{4\}/\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*\*/g
s/3[47][0-9]{2\}[- ]*[0-9]\{4\}[- ]*[0-9]\{4\}[- ]*[0-9]\{3\}/\*\*\*\*-\*\*\*\*-\*\*\*\*-\*\*\*/g
Say CCENGINE=ccengine.sed
INFILE=
OUTFILE =
If you have the dump of database as a bcp or sqlload or just a file , just need to translate the file using following sed command
sed -f $CCENGINE $INFILE >$OUTFILE
bcp or sqlload back dependending on whether you are using Sybase or Oracle.Keep it Simple !
Monday, January 23, 2012
Choice Overload
Thursday, June 9, 2011
An attempt at visualizing the future ...
Wednesday, March 16, 2011
India-New Zealand Free Trade Agreement-Opportunities and Challenges
The presentation ,as part of individual study in International business course is based on India – New Zealand Joint Study for a Free Trade Agreement/Comprehensive Economic Cooperation Agreement and refers several international business resources and focuses specifically from a NZ business point of view.
Sunday, October 17, 2010
TranzMetro -A Marketing Perspective
Tuesday, May 4, 2010
Effects of Increasing Mining on Crown Land Prepared for the New Zealand Government
‘What is the effect of increasing mining on Crown land?’
A variety of stakeholders have interests in the issue of mining on Crown land. These include various government organisations, the mining industry, environmental activists and the
A Causal Loop Diagram is used to show how mining on Crown land might increase government revenue but also negatively impact Ecotourism and
The primary policy suggestion is to create a Mining Rehabilitation Fund which would include funds for both environmental rehabilitation and public relations engagement. Ultimately, it would aim to mitigate the negative consequences of mining and allow
The complete Systems Thinking Study of the Effects of Increasing Mining on Crown Land Prepared for the New Zealand Government done by team members Souradeep Gupta,Jenet Mwanza ,Rodney Porto,Roshan Ramachandran,Carolyn Shivanandan for Problem Solving & Decision Making course can be found here .