Bonjour auriez vous un code java sous la main pour calculer la clé RIB d un compte bancaire.
J'essaie de le faire, mais en vain :(
Merci de votre aide
Bonjour,
Voici une methode Delphi [ désolé ;-) ] qui permet de vérifier la validité d'un RIB/RIP.
Rem.: Ord renvoie la valeur ASCII d'un caractère (Ex.: Ord('A') => 65) StrToIntDef renvoie la valeur entière d'un nombre transmis comme chaine de caractère avec une valeur par défaut en cas d'erreur de conversion (Ex.: StrToIntDef('1234', -1) => 1234) (Ex.: StrToIntDef('12AB', -1) => -1)
Pour obtenir la clé RIB:
n4 := 97 - ((62 * n1 + 34 * n2 + 3 * n3) mod 97);
et adapter le reste... ;-)
function RIBPValide(NoCpte: string): Boolean; var n1, n2, n3, n4, i: Integer; begin Result := False; // Longueur correcte ? if Length(NoCpte) <> 23 then Exit;
for i := 11 to 21 do begin // On transforme les lettres en chiffres if NoCpte[i] in ['A'..'I'] then NoCpte[i] := Char(Ord(NoCpte[i]) - 16) else if NoCpte[i] in ['J'..'R'] then NoCpte[i] := Char(Ord(NoCpte[i]) - 25) else if NoCpte[i] in ['S'..'Z'] then NoCpte[i] := Char(Ord(NoCpte[i]) - 33) end;
if (n1 < 0) or (n2 < 0) or (n3 < 0) or (n4 < 0) then Exit;
// Vérifier le n° sur la base d'un modulo 97 Result := ((62 * n1 + 34 * n2 + 3 * n3 + n4) mod 97 = 0); end;
-- Philippe.
fraginfo@free.fr a demandé:
Bonjour auriez vous un code java sous la main pour calculer la clé RIB
d un compte bancaire.
J'essaie de le faire, mais en vain :(
Merci de votre aide
Bonjour,
Voici une methode Delphi [ désolé ;-) ] qui permet de vérifier la
validité d'un RIB/RIP.
Rem.:
Ord renvoie la valeur ASCII d'un caractère (Ex.: Ord('A') => 65)
StrToIntDef renvoie la valeur entière d'un nombre transmis comme chaine
de caractère avec une valeur par défaut en cas d'erreur de conversion
(Ex.: StrToIntDef('1234', -1) => 1234)
(Ex.: StrToIntDef('12AB', -1) => -1)
Pour obtenir la clé RIB:
n4 := 97 - ((62 * n1 + 34 * n2 + 3 * n3) mod 97);
et adapter le reste... ;-)
function RIBPValide(NoCpte: string): Boolean;
var
n1, n2, n3, n4, i: Integer;
begin
Result := False;
// Longueur correcte ?
if Length(NoCpte) <> 23 then
Exit;
for i := 11 to 21 do
begin
// On transforme les lettres en chiffres
if NoCpte[i] in ['A'..'I'] then
NoCpte[i] := Char(Ord(NoCpte[i]) - 16)
else if NoCpte[i] in ['J'..'R'] then
NoCpte[i] := Char(Ord(NoCpte[i]) - 25)
else if NoCpte[i] in ['S'..'Z'] then
NoCpte[i] := Char(Ord(NoCpte[i]) - 33)
end;
Bonjour auriez vous un code java sous la main pour calculer la clé RIB d un compte bancaire.
J'essaie de le faire, mais en vain :(
Merci de votre aide
Bonjour,
Voici une methode Delphi [ désolé ;-) ] qui permet de vérifier la validité d'un RIB/RIP.
Rem.: Ord renvoie la valeur ASCII d'un caractère (Ex.: Ord('A') => 65) StrToIntDef renvoie la valeur entière d'un nombre transmis comme chaine de caractère avec une valeur par défaut en cas d'erreur de conversion (Ex.: StrToIntDef('1234', -1) => 1234) (Ex.: StrToIntDef('12AB', -1) => -1)
Pour obtenir la clé RIB:
n4 := 97 - ((62 * n1 + 34 * n2 + 3 * n3) mod 97);
et adapter le reste... ;-)
function RIBPValide(NoCpte: string): Boolean; var n1, n2, n3, n4, i: Integer; begin Result := False; // Longueur correcte ? if Length(NoCpte) <> 23 then Exit;
for i := 11 to 21 do begin // On transforme les lettres en chiffres if NoCpte[i] in ['A'..'I'] then NoCpte[i] := Char(Ord(NoCpte[i]) - 16) else if NoCpte[i] in ['J'..'R'] then NoCpte[i] := Char(Ord(NoCpte[i]) - 25) else if NoCpte[i] in ['S'..'Z'] then NoCpte[i] := Char(Ord(NoCpte[i]) - 33) end;
function RsetVL(){formulaire.reset();formulaire.Banque.focus();cxv=0}
</script> </head> <body> <b><font color="#008000">Touche</font></b> <b><font color="#FF0000">Echap</font></b> = <font color="#0000FF">efface le formulaire</font><br> <b><font color="#008000">Touche</font></b> <b><font color="#FF0000">Entrée</font></b> = <font color="#0000FF">passe au champ suivant</font><br> <font color="#008000"><b>NB </b></font>: vous pouvez taper les chiffres a la suite,<br> le curseeur passera au champ suivant automatiquement<br> <form name="formulaire">
Banque : <input type="text" name="Banque" size="5" onkeypress=' if (formulaire.Banque.value.length==5) {cxv=window.event.keyCode;window.event.keyCode="";formulaire.Guichet.focus();} if (window.event.keyCode=){formulaire.Guichet.focus()}'><br>
Guichet : <input type="text" name="Guichet" size="5" onfocus='window.event.keyCode;formulaire.Guichet.value=String.fromCharCode(cxv)' onkeypress=' if (window.event.keyCode='){RsetVL()} if (formulaire.Guichet.value.length==5) {cxv=window.event.keyCode;window.event.keyCode="";formulaire.Compte.focus();} if (window.event.keyCode=){formulaire.Compte.focus()}'><br>
Compte : <input type="text" name="Compte" size="12" title="Enter = Calcule" onfocus='window.event.keyCode;formulaire.Compte.value=String.fromCharCode(cxv)' onkeypress=' if (formulaire.Compte.value.length=) {window.event.keyCode="";verif();} if (window.event.keyCode='){RsetVL()} if (window.event.keyCode=){verif()}'><br>
function RsetVL(){formulaire.reset();formulaire.Banque.focus();cxv=0}
</script>
</head>
<body>
<b><font color="#008000">Touche</font></b> <b><font color="#FF0000">Echap</font></b> =
<font color="#0000FF">efface le formulaire</font><br>
<b><font color="#008000">Touche</font></b> <b><font color="#FF0000">Entrée</font></b> =
<font color="#0000FF">passe au champ suivant</font><br>
<font color="#008000"><b>NB </b></font>: vous pouvez taper les chiffres a la suite,<br>
le curseeur passera au champ suivant automatiquement<br>
<form name="formulaire">
Banque : <input type="text" name="Banque" size="5" onkeypress='
if (formulaire.Banque.value.length==5) {cxv=window.event.keyCode;window.event.keyCode="";formulaire.Guichet.focus();}
if (window.event.keyCode==13){formulaire.Guichet.focus()}'><br>
Guichet : <input type="text" name="Guichet" size="5" onfocus='window.event.keyCode=13;formulaire.Guichet.value=String.fromCharCode(cxv)' onkeypress='
if (window.event.keyCode==27){RsetVL()}
if (formulaire.Guichet.value.length==5) {cxv=window.event.keyCode;window.event.keyCode="";formulaire.Compte.focus();}
if (window.event.keyCode==13){formulaire.Compte.focus()}'><br>
Compte : <input type="text" name="Compte" size="12" title="Enter = Calcule" onfocus='window.event.keyCode=13;formulaire.Compte.value=String.fromCharCode(cxv)' onkeypress='
if (formulaire.Compte.value.length==11) {window.event.keyCode="";verif();}
if (window.event.keyCode==27){RsetVL()}
if (window.event.keyCode==13){verif()}'><br>
function RsetVL(){formulaire.reset();formulaire.Banque.focus();cxv=0}
</script> </head> <body> <b><font color="#008000">Touche</font></b> <b><font color="#FF0000">Echap</font></b> = <font color="#0000FF">efface le formulaire</font><br> <b><font color="#008000">Touche</font></b> <b><font color="#FF0000">Entrée</font></b> = <font color="#0000FF">passe au champ suivant</font><br> <font color="#008000"><b>NB </b></font>: vous pouvez taper les chiffres a la suite,<br> le curseeur passera au champ suivant automatiquement<br> <form name="formulaire">
Banque : <input type="text" name="Banque" size="5" onkeypress=' if (formulaire.Banque.value.length==5) {cxv=window.event.keyCode;window.event.keyCode="";formulaire.Guichet.focus();} if (window.event.keyCode=){formulaire.Guichet.focus()}'><br>
Guichet : <input type="text" name="Guichet" size="5" onfocus='window.event.keyCode;formulaire.Guichet.value=String.fromCharCode(cxv)' onkeypress=' if (window.event.keyCode='){RsetVL()} if (formulaire.Guichet.value.length==5) {cxv=window.event.keyCode;window.event.keyCode="";formulaire.Compte.focus();} if (window.event.keyCode=){formulaire.Compte.focus()}'><br>
Compte : <input type="text" name="Compte" size="12" title="Enter = Calcule" onfocus='window.event.keyCode;formulaire.Compte.value=String.fromCharCode(cxv)' onkeypress=' if (formulaire.Compte.value.length=) {window.event.keyCode="";verif();} if (window.event.keyCode='){RsetVL()} if (window.event.keyCode=){verif()}'><br>