• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

IBAN

Community Beginner ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

Bonjour,

Ce qui est classique, je dois vérifié si l'IBAN (ou tous autres) est correct.

Existe-t-il des solutions en CF ?

Sinon comment s'y prendre ?

Merci par avance

 

Hello,

What is classic, I have to check if the IBAN (or any others) is correct.

Are there solutions in CF?

Otherwise how to go about it?

thanks in advance

TOPICS
Documentation , Security

Views

364

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 30, 2022 Jun 30, 2022

You will find ColdFusion code to verify IBAN at cfml.de.

BKBK_0-1656590987721.png

 

Quite generous of Christian Henkel. If the code helps you, then please thank him at info[at]cfml.de.

Votes

Translate

Translate
Community Expert ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

You will find ColdFusion code to verify IBAN at cfml.de.

BKBK_0-1656590987721.png

 

Quite generous of Christian Henkel. If the code helps you, then please thank him at info[at]cfml.de.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2022 Jul 03, 2022

Copy link to clipboard

Copied

@Jean-Marie22691987kfb3 , please note that, Google Translate interferes with the code, introducing errors! For example, the translation into French or English results in

 

REfind("[AZ][AZ]", local.country) == 0

 

which is wrong. 

 

The correct statement is of course:

 

REfind("[A-Z][A-Z]", local.country) == 0

 

<cfscript>
/*	
Origine: https://www.cfml.de/index.cfm?CFID=244157468&CFTOKEN=99092613&at=cf_talk&pt=Forum_Detail&forum_id=304CF7E8-ED9B-9AFC-987D7980EC711985

Auteur: Jens, 13.12.2013 10:12

Je viens d'écrire deux fonctions qui vérifient la structure de l'IBAN et du BIC.
Pour que la roue n'ait pas à être réinventée encore et encore, je poste le code ici pour les développeurs intéressés.
Le code peut être utilisé librement.
	
*/	
	

	
/**
* Vérifie si la chaîne peut être un IBAN
*
*/
public boolean function isIBAN (required string iban) {
	// offset pour convertir les lettres en chiffres
	local.offset = 55;
	
	// Prépare
	arguments.iban = ucase(arguments.iban);
	arguments.iban = replace(arguments.iban, " ", "", "all");
	local.len = len(arguments.iban);
	
	// Vérifie la longueur
	if ( local.len > 34 or local.len < 15)
	return false ;
	
	// Vérifie le code pays
	local.country = left(arguments.iban, 2);
	if ( REfind("[A-Z][A-Z]", local.country) == 0 )
	return false ;
	
	// Tester la somme de contrôle
	local.checksum = mid(arguments.iban, 3, 2);
	if ( REfind("[0-9][0-9]", local.checksum) == 0 )
	return false ;
	
	// Convertit le code pays en nombre
	local.numericCountry = toString( asc(local.country) - local.offset ) & toString( asc( right(local.country, 1) ) - local.offset );
	
	local.numbers = "" ;
	for (i = 5; i <= local.len; i = i + 1) {
		local.c = mid(arguments.iban, i, 1);
		if ( isNumeric(local.c) ) {
			local.numbers = local.numbers & local.c;
		} else {
			// Convertit les lettres en nombres
			local.numbers = local.numbers & toString( asc(local.c) - local.offset );
		}
	}
	
	// Coldfusion ne peut pas gérer les grands nombres, mais Java le peut!
	local.bigInt = createObject( "java", "java.math.BigInteger" ).init(	javaCast( "string", local.numbers & local.numericCountry & local.checksum ) );
	local.modBase = createObject( "java", "java.math.BigInteger" ).init( javaCast( "string", "97" ) );
	
	// Calcule modulo
	local.result = local.bigInt.mod( local.modBase ).toString();	
	if (local.result != "1")
	return false;
	
	// Tout va bien
	return true;
}
</cfscript>

isIBAN("FR14 2004 1010 0505 0001 3M02 606"): <strong><cfoutput>#isIBAN("FR14 2004 1010 0505 0001 3M02 606")#</cfoutput></strong>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 07, 2022 Jul 07, 2022

Copy link to clipboard

Copied

LATEST

Hi @Jean-Marie22691987kfb3 ,

Could you please let us know whether the code meets your requirements.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation