Tuesday, August 16, 2011

[Java] Credit Card validity checker using Luhn and known MII

I received an email from Mr.Chua yesterday seeking help on behalf of "dignitykitchen" to address the matter on
1. whether there is a way to differentiate the various credit/debit cards eg. AMEX, VISA, DINNERS etc?
2. Is it possible to read the card to get the card number and tell the type of card?

Suddenly the thought of using this as a case study for Java programming I assignment crossed my mind. 

Nonetheless, I could not wait till next semester to start to code and quickly hack up a POC using Java for Mr.Chua. Usually, I code in C++ or python, since we are going to learn Java Programming I soon therefore I shall code more often in Java. The implementation can be ported on C, C++, Java, python, android, arduino (to hook up with a magnetic card reader, more later) etc. As long as the programming "logic" is sound, it can be demonstrated using different language. It is analogous to saying "I love you" in different language..... You get the idea.

The code uses luhn algorithm to check the validity of the credit card number, through a series of steps on choosing alternate number starting from the LSB, perform calculation and finally a MOD10 . The code does NOT check the validity of the card with the credit provider. Features such as manual input, identifying credit card provider were added. The code base can be expanded to recognize more info from the number itself. 

Apparently I misinterpreted the word "read" from the email received, after realizing it from another colleague's suggestion on using magnetic card reader with an MCU to "read" in the data from the card and do the validation checks on the MCU iteself. Anyway, the validation code can be ported to the said MCU... e.g Arduino with a magnetic card reader.

NOTE: Source code is for academic use only.
1. place Main.Java and LuhnCheck.java in the same folder. Compile (I did it using javac) and run.

Main.java

Luhn.java

there goes my lunch time...... duhz.....

Sunday, July 24, 2011

loading external *.JS as per XSS

test external *.js, for the different flavours of XSS

">

Friday, July 8, 2011

[DIY] Arduino VU Spectrum Analyzer

While searching on the Internet on interesting way of approaching the purpose of doing Fourier transform and why we need FT for my teaching.

I came across a fellow arduino user (http://andydoro.com/vulol/) that posted his toy project on using Fast Fourier Transform (FFT) to make a VU meter. Couple of years back, I did played with my home made wireless VU using electronic components that is available from the store. I am quite surprised that  an 8bit Arduino is capable of doing FFT, never did I thought of using it because usually I am using a PIC32dsp for transforming from time domain to frequency domain for signal manipulation purposes. Arduino did gave me the WOW moment for a while.

From the detailed explanations on his website , i downloaded his code and hook up my LOLshield on my laptop playing some song to enjoy the geekness of arduino LOL shield VU meter.... To my dismay, it doesn't work "out of the box". It just display a 1 liner.... both plug in to my laptop and plug out from my laptop. Seems that the VU only picking up white noise from the ambiance. The connections are correct, pin A5 for +ve signal from the left channel and ground to common ground of the mini stereo jack. 


To further complicate the issues, I tried on a variety of input of devices ranging from my android phone, my speakers with a BIG ASS amp etc. Suddenly IT hit me, probably the analog signal read in at pin A5 is too low to be detected as a usable base band signal where the FFT would chop up the signal in time domain to be put into frequency domain and the harmonics combined as 14 outputs (LOL shield only have 14 columns of LED).

There are 2 ways to put the analog in on steroids. The hardware method, I would use a TIP31C or TIP41C audio amplifying circuit OR the software method by scaling up the data read in on A5. I choose the software method, it requires little time to prove my hypotheses compared to the hardware method.....

It is kind of worrying.... the VU is more sensitive now ,picking up ambiance noise which is reflected in the below picture. The LEDs are lighting up ....More work needed to change part of the code to filter AWGN....

But once I plug the mini stereo jack to a Y connector with the headphone stereo jack into my laptop, the noise signal disappear.
Played one of my favorite songs with rich sound texture... Sorry for poor sound quality... I am playing it through my headphone.... still office hour and I can't turn on the LOUD music...


enjoy the code. you would need to place the FFT and charlieplexing libraries in your arduino\lib\ folder to compile successfully.

Saturday, June 18, 2011

BGP awesomeness with Packet Tracer 5.3.2

With Packet Tracer 5.3.2 you can experiment with BGP (eBGP)

It serves as a good tool for a refresher, especially for poor chap like without exclusive access to the cisco racks....




Here I demo Cross AS BGP. Not all the BGP peers have a direct peering. I use the "network" command to do the routing.

Common mistakes that might occur
1. Peering with BGP peer on the wrong AS
2. Peering with BGP peer on the wrong IP subnet
3. Configure wrong AS for BGP on the victim router
4. and the list go on....

to verify your settings...
sh ip bgp

sh ip bgp neigh

come code for your reference.....

Wednesday, June 15, 2011

my first attempt: solar cooker

Get a BIG cardboard, some aluminium foil and adhesive.
1 black or dark colored cooking vessel.
1 small piece of wood as insulator.
1 clear plastic bag. I got mine from the fresh fruits section at NTUC... but realise it was a lil too small to fit the flower pot I am going to use.


We are going to form a cone shape with the cardboard, hence make a cut with a diameter of 25cm or more to accommodate it. Paste the foil on the cardboard, shinny side up. I made a mistake of inverting it....oh well...

I was hunting for a pot like apparatus to secure my new toy... Went hunting around and discover some flower pots......


weather check.... it was cloudy.... not a good day for solar cooking....

I am experimenting whether solar cooking rice or sweet potato will be edible? Typical Asian staple.

arrange in this order and secure with cable tie.

/\
/ \
/ \_______
| air |
| |
|cooking ware|
| insulator |
|plastic bag|
-------------



Just in case you guys wondered where did the flower pot went to ...

Cooking time -> 1245 - 430pm...
the plastic bag burst....

Conclusion.....
The rice is not cooked..... but the rice water is warmer then room temperature.
The sweet potato is not cooked thoroughly. Never buy $1 sweet potato from NTUC... rotten ...

next up.... improvised on
a. neater foil reflector will lesser creases when pasting it to cardbord.
1. weather check appratus..
2. temperature check apparatus....
3. quantify the heat generated from this solar cooker.. (a lil far fetched)