Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: add an example of how to generate a RIB #9

Open
giraud10 opened this issue Jun 17, 2022 · 1 comment · May be fixed by #14
Open

Docs: add an example of how to generate a RIB #9

giraud10 opened this issue Jun 17, 2022 · 1 comment · May be fixed by #14

Comments

@giraud10
Copy link
Contributor

No description provided.

@giraud10
Copy link
Contributor Author

version: "1"
seed: 42
masking:
  # CODE BANQUE (à modifier en récupérant toute la liste des codes banque disponible)
  - selector:
      jsonpath: "CODE_BANQUE"
    masks:
      - add-transient: ""
      - regex: "[0-9]{5}"
      # - randomChoiceInUri: "file://codeBanque.csv"

  # CODE GUICHET 
  - selector:
      jsonpath: "CODE_GUICHET"
    masks:
      - add-transient: "{{randNumeric 5}}"
  
  # 10 premiers chiffres/lettres du n° compte
  - selector:
      jsonpath: "NUMERO_COMPTE_10"
    masks:
      - add-transient: ""
      - regex: "([0-9A-Z]-){9}[0-9A-Z]"
  
  # Dernier caractère du n° compte
  - selector:
      jsonpath: "NUMERO_COMPTE_11"
    masks:
      - add-transient: ""
      - regex: "[0-9A-Z]"

  # Conversion n° compte en chiffres
  - selector:
      jsonpath: "NUMERO_COMPTE_10_ENC"
    mask:
      add-transient : '{{$a := split "-" .NUMERO_COMPTE_10}}{{range $i := $a}}{{if eq $i "A" "J"}}1{{else if eq $i "B" "K" "S"}}2{{else if eq $i "C" "L" "T"}}3{{else if eq $i "D" "M" "U"}}4{{else if eq $i "E" "N" "V"}}5{{else if eq $i "F" "O" "W"}}6{{else if eq $i "G" "P" "X"}}7{{else if eq $i "H" "Q" "Y"}}8{{else if eq $i "I" "R" "Z"}}9{{else}}{{$i}}{{end}}{{end}}'
  
  - selector:
      jsonpath: "NUMERO_COMPTE_11_ENC"
    mask:
      add-transient : '{{if eq .NUMERO_COMPTE_11 "A" "J"}}1{{else if eq .NUMERO_COMPTE_11 "B" "K" "S"}}2{{else if eq .NUMERO_COMPTE_11 "C" "L" "T"}}3{{else if eq .NUMERO_COMPTE_11 "D" "M" "U"}}4{{else if eq .NUMERO_COMPTE_11 "E" "N" "V"}}5{{else if eq .NUMERO_COMPTE_11 "F" "O" "W"}}6{{else if eq .NUMERO_COMPTE_11 "G" "P" "X"}}7{{else if eq .NUMERO_COMPTE_11 "H" "Q" "Y"}}8{{ else if eq .NUMERO_COMPTE_11 "I" "R" "Z"}}9{{else}}{{.NUMERO_COMPTE_11}}{{end}}'
  
  # n° compte sans les "-"
  - selector:
      jsonpath: "NUMERO_COMPTE_10_"
    mask:
      add-transient: '{{$a := split "-" .NUMERO_COMPTE_10}}{{range $i := $a}}{{$i}}{{end}}'

  # RIB sans la clé
  - selector:
      jsonpath: "VALEUR_RIB"
    mask:
      add-transient: '{{.CODE_BANQUE}}{{.CODE_GUICHET}}{{.NUMERO_COMPTE_10_}}{{.NUMERO_COMPTE_11}}'

  # RIB sans la clé (en chiffres) pour pouvoir faire le calcul de la clé
  - selector:
      jsonpath: "VALEUR_RIB_ENC"
    mask:
      add-transient: '{{.CODE_BANQUE}}{{.CODE_GUICHET}}{{.NUMERO_COMPTE_10_ENC}}{{.NUMERO_COMPTE_11_ENC}}'
  
  # Calcul de la clé du RIB
  - selector:
      jsonpath: "CLE_RIB"
    masks:
      - add-transient: '{{ sub 97 (mod (add (mul (int64 .CODE_BANQUE) 89) (mul (int64 .CODE_GUICHET) 15) (mul (int64 (atoi .VALEUR_RIB_ENC)) 3)) 97)}}'

  # Totalité du RIB
  - selector:
      jsonpath: "RIB"
    masks:
      - add: '{{(toString .VALEUR_RIB)}}{{if eq (len .CLE_RIB) 1}}0{{(toString .CLE_RIB)}}{{else}}{{(toString .CLE_RIB)}}{{end}}'

Pour la conversion du n° compte en chiffres, il existe une formule:
(charValue + 2**((charValue-10)/9)) mod 10

On peut faire "{{add (sub 'Z' 'A') 1}}" pour trouver charValue
Problème: Comment faire pour trouver la puissance ?

@giraud10 giraud10 linked a pull request Jun 30, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant