<?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: Demo for Luhn algorithm in PHP</title>
	<atom:link href="http://javier.rodriguez.org.mx/index.php/2006/02/24/demo-for-luhn-algorithm-in-php/feed" rel="self" type="application/rss+xml" />
	<link>http://javier.rodriguez.org.mx/index.php/2006/02/24/demo-for-luhn-algorithm-in-php?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=demo-for-luhn-algorithm-in-php</link>
	<description>random musings</description>
	<lastBuildDate>Sun, 22 May 2011 14:02:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: dbl</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/02/24/demo-for-luhn-algorithm-in-php/comment-page-1#comment-131526</link>
		<dc:creator>dbl</dc:creator>
		<pubDate>Mon, 18 Aug 2008 20:06:55 +0000</pubDate>
		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=53#comment-131526</guid>
		<description>Ok, Sry ppl, here is the debuged (working) version ... a new try to post.
Maybe the calculation have to be done recursive (see wikipedia)

/**
* Luhn-Algorithm for Creditcards an Bankaccounts
* Creditcards exposure is everytime 2121... in length of the cardnumber
* Banknumbers will have for each bank a own exposure.
* I hope all Verificationnumbers will be calculatet for Bankaccounts with this algorithm.
* In Some Cases the modulo have to be changed. On Creditcards the module everytime is 10.
* Please report bugs to doubleatdumpitde
*
* @param string $nb   have to be string and numeric because double is to small
* @param string $exp  have to be string and numeric because double is to small
* @param int    $mod  used modulo
* @return boolean
*/
function _luhn( $nb, $exp = &#039;2121212121212121&#039;, $mod = 10 )
{
// first validate parameters
if( !is_string( $nb ) )
return PEAR::raiseError( &#039;given parameter nb (number) is not a string&#039;, null );
if( !is_string( $exp ) )
return PEAR::raiseError( &#039;given parameter exp (exposure) is not a string&#039;, null );
if( !is_numeric( $nb ) )
return PEAR::raiseError( &#039;given parameter nb (number) is not numeric&#039;, null );
if( !is_numeric( $exp ) )
return PEAR::raiseError( &#039;given parameter exp (exposure) is not numeric&#039;, null );
if( !is_integer( $mod ) )
return PEAR::raiseError( &#039;given parameter mod (modulo) is not numeric&#039;, null );
if( 0 &gt;= $nb )
return PEAR::raiseError( &#039;given parameter nb (number) could not be lower than or zero&#039;, null );
if( strlen($exp) != strlen( $nb ) )
return PEAR::raiseError( &#039;given parameter exp (exposure) is not in characterlength of nb (number)&#039;, null );

// lets do the calculation
for( $sum = 0, $pos = 0; $pos &lt; strlen( $nb ); $pos++ )
{
$x = $exp[$pos]*$nb[$pos];
$sum += 9 &gt; $x ? $x : substr($x,0,1)+substr($x,1,1);
}
return(0&lt;$sum&amp;&amp;0==$sum%$mod);
}

isn&#039;t it easy ;)</description>
		<content:encoded><![CDATA[<p>Ok, Sry ppl, here is the debuged (working) version &#8230; a new try to post.<br />
Maybe the calculation have to be done recursive (see wikipedia)</p>
<p>/**<br />
* Luhn-Algorithm for Creditcards an Bankaccounts<br />
* Creditcards exposure is everytime 2121&#8230; in length of the cardnumber<br />
* Banknumbers will have for each bank a own exposure.<br />
* I hope all Verificationnumbers will be calculatet for Bankaccounts with this algorithm.<br />
* In Some Cases the modulo have to be changed. On Creditcards the module everytime is 10.<br />
* Please report bugs to doubleatdumpitde<br />
*<br />
* @param string $nb   have to be string and numeric because double is to small<br />
* @param string $exp  have to be string and numeric because double is to small<br />
* @param int    $mod  used modulo<br />
* @return boolean<br />
*/<br />
function _luhn( $nb, $exp = &#8217;2121212121212121&#8242;, $mod = 10 )<br />
{<br />
// first validate parameters<br />
if( !is_string( $nb ) )<br />
return PEAR::raiseError( &#8216;given parameter nb (number) is not a string&#8217;, null );<br />
if( !is_string( $exp ) )<br />
return PEAR::raiseError( &#8216;given parameter exp (exposure) is not a string&#8217;, null );<br />
if( !is_numeric( $nb ) )<br />
return PEAR::raiseError( &#8216;given parameter nb (number) is not numeric&#8217;, null );<br />
if( !is_numeric( $exp ) )<br />
return PEAR::raiseError( &#8216;given parameter exp (exposure) is not numeric&#8217;, null );<br />
if( !is_integer( $mod ) )<br />
return PEAR::raiseError( &#8216;given parameter mod (modulo) is not numeric&#8217;, null );<br />
if( 0 &gt;= $nb )<br />
return PEAR::raiseError( &#8216;given parameter nb (number) could not be lower than or zero&#8217;, null );<br />
if( strlen($exp) != strlen( $nb ) )<br />
return PEAR::raiseError( &#8216;given parameter exp (exposure) is not in characterlength of nb (number)&#8217;, null );</p>
<p>// lets do the calculation<br />
for( $sum = 0, $pos = 0; $pos &lt; strlen( $nb ); $pos++ )<br />
{<br />
$x = $exp[$pos]*$nb[$pos];<br />
$sum += 9 &gt; $x ? $x : substr($x,0,1)+substr($x,1,1);<br />
}<br />
return(0&lt;$sum&amp;&amp;0==$sum%$mod);<br />
}</p>
<p>isn&#8217;t it easy ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dbl</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/02/24/demo-for-luhn-algorithm-in-php/comment-page-1#comment-131519</link>
		<dc:creator>dbl</dc:creator>
		<pubDate>Mon, 18 Aug 2008 19:39:14 +0000</pubDate>
		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=53#comment-131519</guid>
		<description>??</description>
		<content:encoded><![CDATA[<p>??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dbl</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/02/24/demo-for-luhn-algorithm-in-php/comment-page-1#comment-131518</link>
		<dc:creator>dbl</dc:creator>
		<pubDate>Mon, 18 Aug 2008 19:37:22 +0000</pubDate>
		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=53#comment-131518</guid>
		<description>Here is a (RIGHT-CODED &amp; STRICT) Algorithm  ... ( do not delete my postings =/ ) it&#039;s your content. But may if you do not want to have qualitiv content - delete it. For German Bankaccounts see the national bank (Deutsche Bundesbank)

... think big ppl ;)

/**
         * Luhn-Algorithm for Creditcards an Bankaccounts
         * Creditcards exposure is everytime 1212... in length of the cardnumber
         * Banknumbers will have for each bank a own exposure.
         * I hope all Verificationnumbers will be calculatet for Bankaccounts with this algorithm.
         * In Some Cases the modulo have to be changed. On Creditcards the module everytime is 10.
         * Please report bugs to doubleatdumpitde.
         *
         * @param string $nb   have to be string and numeric because double is to small
         * @param string $exp  have to be string and numeric because double is to small
         * @param int    $mod  used modulo
         * @return boolean
         */
        function _luhn( $nb, $exp = &#039;1212121212121212&#039;, $mod = 10 )
        {
            // first validate parameters
            if( !is_string( $nb ) )
                return PEAR::raiseError( &#039;given parameter nb (number) is not a string&#039;, null );
            if( !is_string( $exp ) )
                return PEAR::raiseError( &#039;given parameter exp (exposure) is not a string&#039;, null );
            if( !is_numeric( $nb ) )
                return PEAR::raiseError( &#039;given parameter nb (number) is not numeric&#039;, null );
            if( !is_numeric( $exp ) )
                return PEAR::raiseError( &#039;given parameter exp (exposure) is not numeric&#039;, null );
            if( !is_integer( $mod ) )
                return PEAR::raiseError( &#039;given parameter mod (modulo) is not numeric&#039;, null );
            if( 0 &gt;= $int )
                return PEAR::raiseError( &#039;given parameter nb (number) could not be lower than or zero&#039;, null );
            if( strlen($exp) != strlen( $int ) )
                return PEAR::raiseError( &#039;given parameter exp (exposure) is not in characterlength of nb (number)&#039;, null );

            // lets do the calculation
            for( $sum = 0, $pos = 0; $pos = $x ? $x : $x[0]+$x[1];
            }

            return(0==$sum%$mod);
        }</description>
		<content:encoded><![CDATA[<p>Here is a (RIGHT-CODED &amp; STRICT) Algorithm  &#8230; ( do not delete my postings =/ ) it&#8217;s your content. But may if you do not want to have qualitiv content &#8211; delete it. For German Bankaccounts see the national bank (Deutsche Bundesbank)</p>
<p>&#8230; think big ppl ;)</p>
<p>/**<br />
         * Luhn-Algorithm for Creditcards an Bankaccounts<br />
         * Creditcards exposure is everytime 1212&#8230; in length of the cardnumber<br />
         * Banknumbers will have for each bank a own exposure.<br />
         * I hope all Verificationnumbers will be calculatet for Bankaccounts with this algorithm.<br />
         * In Some Cases the modulo have to be changed. On Creditcards the module everytime is 10.<br />
         * Please report bugs to doubleatdumpitde.<br />
         *<br />
         * @param string $nb   have to be string and numeric because double is to small<br />
         * @param string $exp  have to be string and numeric because double is to small<br />
         * @param int    $mod  used modulo<br />
         * @return boolean<br />
         */<br />
        function _luhn( $nb, $exp = &#8217;1212121212121212&#8242;, $mod = 10 )<br />
        {<br />
            // first validate parameters<br />
            if( !is_string( $nb ) )<br />
                return PEAR::raiseError( &#8216;given parameter nb (number) is not a string&#8217;, null );<br />
            if( !is_string( $exp ) )<br />
                return PEAR::raiseError( &#8216;given parameter exp (exposure) is not a string&#8217;, null );<br />
            if( !is_numeric( $nb ) )<br />
                return PEAR::raiseError( &#8216;given parameter nb (number) is not numeric&#8217;, null );<br />
            if( !is_numeric( $exp ) )<br />
                return PEAR::raiseError( &#8216;given parameter exp (exposure) is not numeric&#8217;, null );<br />
            if( !is_integer( $mod ) )<br />
                return PEAR::raiseError( &#8216;given parameter mod (modulo) is not numeric&#8217;, null );<br />
            if( 0 &gt;= $int )<br />
                return PEAR::raiseError( &#8216;given parameter nb (number) could not be lower than or zero&#8217;, null );<br />
            if( strlen($exp) != strlen( $int ) )<br />
                return PEAR::raiseError( &#8216;given parameter exp (exposure) is not in characterlength of nb (number)&#8217;, null );</p>
<p>            // lets do the calculation<br />
            for( $sum = 0, $pos = 0; $pos = $x ? $x : $x[0]+$x[1];<br />
            }</p>
<p>            return(0==$sum%$mod);<br />
        }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Booth Graphics</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/02/24/demo-for-luhn-algorithm-in-php/comment-page-1#comment-129122</link>
		<dc:creator>Booth Graphics</dc:creator>
		<pubDate>Mon, 14 Jul 2008 23:04:18 +0000</pubDate>
		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=53#comment-129122</guid>
		<description>I agree with Lawrence your algorithm doesn&#039;t validate

Thanks,

Mike</description>
		<content:encoded><![CDATA[<p>I agree with Lawrence your algorithm doesn&#8217;t validate</p>
<p>Thanks,</p>
<p>Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lawrence</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/02/24/demo-for-luhn-algorithm-in-php/comment-page-1#comment-56734</link>
		<dc:creator>Lawrence</dc:creator>
		<pubDate>Wed, 30 May 2007 18:24:24 +0000</pubDate>
		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=53#comment-56734</guid>
		<description>I don&#039;t think your algorithm is correct. Among others, it fails on the test Visa number: 4111111111111111.

-L</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think your algorithm is correct. Among others, it fails on the test Visa number: 4111111111111111.</p>
<p>-L</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pablo</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/02/24/demo-for-luhn-algorithm-in-php/comment-page-1#comment-773</link>
		<dc:creator>Pablo</dc:creator>
		<pubDate>Wed, 03 May 2006 03:56:43 +0000</pubDate>
		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=53#comment-773</guid>
		<description>Un agregado, para que aclare mi mensaje anterior: la linea 
$num = $_GET[&#039;number&#039;]; 
no esta funcionando correctamente, de hecho, en tu ejemplo web no funciona. 
Nos vemos, amigo.</description>
		<content:encoded><![CDATA[<p>Un agregado, para que aclare mi mensaje anterior: la linea<br />
$num = $_GET['number'];<br />
no esta funcionando correctamente, de hecho, en tu ejemplo web no funciona.<br />
Nos vemos, amigo.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pablo</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/02/24/demo-for-luhn-algorithm-in-php/comment-page-1#comment-772</link>
		<dc:creator>Pablo</dc:creator>
		<pubDate>Wed, 03 May 2006 03:54:48 +0000</pubDate>
		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=53#comment-772</guid>
		<description>Amigo: a ese ejemplo ponele un submit, pone en lugar de : name=&quot;num&quot; y saca el ACTION que esta de mas y confunde, porque de lo contrario, ese ejemplo no va a funcionar en la puta vida. Un fuerte a abrazo, y de todos modos: GRACIAS!</description>
		<content:encoded><![CDATA[<p>Amigo: a ese ejemplo ponele un submit, pone en lugar de : name=&#8221;num&#8221; y saca el ACTION que esta de mas y confunde, porque de lo contrario, ese ejemplo no va a funcionar en la puta vida. Un fuerte a abrazo, y de todos modos: GRACIAS!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

