<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Scripting Exercise: Credit Card Challenge</title>
	<atom:link href="http://www.myloadtest.com/credit-card-challenge/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.myloadtest.com/credit-card-challenge/</link>
	<description>Performance Testing with a LoadRunner focus</description>
	<lastBuildDate>Wed, 25 Jan 2012 17:37:19 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Lava Kafle</title>
		<link>http://www.myloadtest.com/credit-card-challenge/#comment-43628</link>
		<dc:creator>Lava Kafle</dc:creator>
		<pubDate>Sun, 10 Jan 2010 07:53:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.myloadtest.com/?p=71#comment-43628</guid>
		<description>Why considered only 300-305 series, If all series could be covered by your code, it would be helpful</description>
		<content:encoded><![CDATA[<p>Why considered only 300-305 series, If all series could be covered by your code, it would be helpful</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramanjaneyulu Narra</title>
		<link>http://www.myloadtest.com/credit-card-challenge/#comment-17083</link>
		<dc:creator>Ramanjaneyulu Narra</dc:creator>
		<pubDate>Mon, 14 Apr 2008 09:32:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.myloadtest.com/?p=71#comment-17083</guid>
		<description>I have written a function that generates a random credit card number first, then verifies for the fuhn algorithm. If everything is fine, then the random number is written to the log. I generated 16 random numbers and then merged them in to a char array. Here is my code. I have validated the values generated by my script. Its working. One thing I missed in this function is that for Diners Club, I didn&#039;t consider the series 36 and 38. I considered only 300 -305 series. As I am generating the random numbers atlest 11 times to generate the credit card number, it should be unique 99.99% of times.

Here is my code:

/**************************************************************************************************************/
 int a,i,j,cardcount=0;
	int cardprefix,forlength,temp;
	int cardtype,arraysize;
    int arrayB[16],sum=0,multiple;
	char creditcardNum[64];
	char tmp[16];
	strcpy(creditcardNum,&quot;&quot;);

// End of Variable Declaration

    j=0;
	do
	{
		
		switch(j)
		{
			case 0: arraysize = 16;
					cardtype = 1;
					forlength = 14;
					//lr_output_message (&quot;The for lenght is: %d&quot;,forlength);
					break;
			case 1: arraysize = 16;
					cardtype = 2;
					forlength = 15;
					//lr_output_message (&quot;The for lenght is: %d&quot;,forlength);
					break;
			case 2: arraysize = 15;
					cardtype = 3;
					forlength = 13;
					//lr_output_message (&quot;The for lenght is: %d&quot;,forlength);
					break;
			case 3: arraysize = 14;
					cardtype = 4;
					forlength = 12;
					//lr_output_message (&quot;The for lenght is: %d&quot;,forlength);
					break;
		};



	do
	{
	   do
	   {
			for(i=0;i&lt;forlength;i++)
			{
				a= rand()%10;
				arrayB[i] = a;
			}
			if(cardtype==1)
			{
				arrayB[14] = rand()%5 + 1;
				arrayB[15] = 5;
			}
			if(cardtype==2)
			{
				arrayB[15] = 4;
			}
			if(cardtype==3)
			{
				if(rand()%2==0)
				{
					arrayB[13] = 4;
				}
				else
				{
					arrayB[13]=7;
				}
				arrayB[14] = 3;
				arrayB[15]=0;
			}
	
			if(cardtype==4)
			{
				arrayB[11] = rand()%6;
				arrayB[12] = 0;
				arrayB[13] = 3;
				arrayB[14]=0;
				arrayB[15]=0;
			}
	
			
			for(i=0;i9)
					{
						temp=temp-9;
					}
				}
				else
				{
					temp=arrayB[i];
				}
				sum = sum + temp;
		   
			}
			if(sum%10==0)
			{
				cardcount++;
				//lr_output_message(&quot;The random number accepted is: %lu&quot;,creditcardNum); 
				
				//lr_output_message (&quot;The number is accepted&quot;);
				strcpy(creditcardNum,&quot;&quot;);
				for(i=15;i&gt;=0;i--)
				{
                    itoa(arrayB[i],tmp,10);
					strcat(creditcardNum,tmp);
				}
				lr_output_message (&quot;%s&quot;,creditcardNum);
				
				sum=0;
			}
			else
			{
				//lr_output_message (&quot;The  number is not accepted&quot;);
				sum=0;
			}
	   }while(sum%10!=0); //internal do while
	}while(cardcount &lt;15); //second do while
	cardcount =0;
	j++;
	
}while(j&lt;4);//last loop
/**************************************************************************************************************************/

Please let me know if you need any further details in this regard.

Thanks and Regards,
Ramanjaneyulu Narra.</description>
		<content:encoded><![CDATA[<p>I have written a function that generates a random credit card number first, then verifies for the fuhn algorithm. If everything is fine, then the random number is written to the log. I generated 16 random numbers and then merged them in to a char array. Here is my code. I have validated the values generated by my script. Its working. One thing I missed in this function is that for Diners Club, I didn&#8217;t consider the series 36 and 38. I considered only 300 -305 series. As I am generating the random numbers atlest 11 times to generate the credit card number, it should be unique 99.99% of times.</p>
<p>Here is my code:</p>
<p>/**************************************************************************************************************/<br />
 int a,i,j,cardcount=0;<br />
	int cardprefix,forlength,temp;<br />
	int cardtype,arraysize;<br />
    int arrayB[16],sum=0,multiple;<br />
	char creditcardNum[64];<br />
	char tmp[16];<br />
	strcpy(creditcardNum,&#8221;");</p>
<p>// End of Variable Declaration</p>
<p>    j=0;<br />
	do<br />
	{</p>
<p>		switch(j)<br />
		{<br />
			case 0: arraysize = 16;<br />
					cardtype = 1;<br />
					forlength = 14;<br />
					//lr_output_message (&#8220;The for lenght is: %d&#8221;,forlength);<br />
					break;<br />
			case 1: arraysize = 16;<br />
					cardtype = 2;<br />
					forlength = 15;<br />
					//lr_output_message (&#8220;The for lenght is: %d&#8221;,forlength);<br />
					break;<br />
			case 2: arraysize = 15;<br />
					cardtype = 3;<br />
					forlength = 13;<br />
					//lr_output_message (&#8220;The for lenght is: %d&#8221;,forlength);<br />
					break;<br />
			case 3: arraysize = 14;<br />
					cardtype = 4;<br />
					forlength = 12;<br />
					//lr_output_message (&#8220;The for lenght is: %d&#8221;,forlength);<br />
					break;<br />
		};</p>
<p>	do<br />
	{<br />
	   do<br />
	   {<br />
			for(i=0;i&lt;forlength;i++)<br />
			{<br />
				a= rand()%10;<br />
				arrayB[i] = a;<br />
			}<br />
			if(cardtype==1)<br />
			{<br />
				arrayB[14] = rand()%5 + 1;<br />
				arrayB[15] = 5;<br />
			}<br />
			if(cardtype==2)<br />
			{<br />
				arrayB[15] = 4;<br />
			}<br />
			if(cardtype==3)<br />
			{<br />
				if(rand()%2==0)<br />
				{<br />
					arrayB[13] = 4;<br />
				}<br />
				else<br />
				{<br />
					arrayB[13]=7;<br />
				}<br />
				arrayB[14] = 3;<br />
				arrayB[15]=0;<br />
			}</p>
<p>			if(cardtype==4)<br />
			{<br />
				arrayB[11] = rand()%6;<br />
				arrayB[12] = 0;<br />
				arrayB[13] = 3;<br />
				arrayB[14]=0;<br />
				arrayB[15]=0;<br />
			}</p>
<p>			for(i=0;i9)<br />
					{<br />
						temp=temp-9;<br />
					}<br />
				}<br />
				else<br />
				{<br />
					temp=arrayB[i];<br />
				}<br />
				sum = sum + temp;</p>
<p>			}<br />
			if(sum%10==0)<br />
			{<br />
				cardcount++;<br />
				//lr_output_message(&#8220;The random number accepted is: %lu&#8221;,creditcardNum); </p>
<p>				//lr_output_message (&#8220;The number is accepted&#8221;);<br />
				strcpy(creditcardNum,&#8221;");<br />
				for(i=15;i&gt;=0;i&#8211;)<br />
				{<br />
                    itoa(arrayB[i],tmp,10);<br />
					strcat(creditcardNum,tmp);<br />
				}<br />
				lr_output_message (&#8220;%s&#8221;,creditcardNum);</p>
<p>				sum=0;<br />
			}<br />
			else<br />
			{<br />
				//lr_output_message (&#8220;The  number is not accepted&#8221;);<br />
				sum=0;<br />
			}<br />
	   }while(sum%10!=0); //internal do while<br />
	}while(cardcount &lt;15); //second do while<br />
	cardcount =0;<br />
	j++;</p>
<p>}while(j&lt;4);//last loop<br />
/**************************************************************************************************************************/</p>
<p>Please let me know if you need any further details in this regard.</p>
<p>Thanks and Regards,<br />
Ramanjaneyulu Narra.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jerry</title>
		<link>http://www.myloadtest.com/credit-card-challenge/#comment-12562</link>
		<dc:creator>jerry</dc:creator>
		<pubDate>Tue, 30 Oct 2007 08:34:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.myloadtest.com/?p=71#comment-12562</guid>
		<description>Is it possible to get your solution also?
Thanks.

You got great website, which I learned from!</description>
		<content:encoded><![CDATA[<p>Is it possible to get your solution also?<br />
Thanks.</p>
<p>You got great website, which I learned from!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart Moncrieff</title>
		<link>http://www.myloadtest.com/credit-card-challenge/#comment-1307</link>
		<dc:creator>Stuart Moncrieff</dc:creator>
		<pubDate>Fri, 27 Oct 2006 05:05:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.myloadtest.com/?p=71#comment-1307</guid>
		<description>http://www.codeproject.com/isapi/isapi_extensions.asp</description>
		<content:encoded><![CDATA[<p><a href="http://www.codeproject.com/isapi/isapi_extensions.asp" rel="nofollow">http://www.codeproject.com/isapi/isapi_extensions.asp</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

