Skip to content

Instantly share code, notes, and snippets.

@CodeBrauer
Last active February 17, 2022 13:49
Show Gist options
  • Save CodeBrauer/69baa015dc77427692cc088ec58a95ca to your computer and use it in GitHub Desktop.
Save CodeBrauer/69baa015dc77427692cc088ec58a95ca to your computer and use it in GitHub Desktop.
Mask IBAN with PHP for privacy (GDPR/DSGVO)

Mask IBAN with PHP for privacy (GDPR/DSGVO)

Masks an IBAN so that the user still recognizes you, but no one else can do anything with it.

<?php
/**
 * Masks an IBAN so that the user still recognizes you, but no one else can do anything with it.
 * @param  string $iban           the iban to mask
 * @param  string $mask_character character/symbol to replace
 * @return string                 masked iban
 */
function maskIBAN($iban, $mask_character = 'X') {
    return substr($iban,0,4) . str_repeat( $mask_character, strlen($iban) - 8 ) . substr($iban, -4);
}
<?php
/**
* Masks an IBAN so that the user still recognizes you, but no one else can do anything with it.
* @param string $iban the iban to mask
* @param string $mask_character character/symbol to replace
* @return string masked iban
*/
function maskIBAN($iban, $mask_character = 'X') {
return substr($iban,0,4) . str_repeat( $mask_character, strlen($iban) - 8 ) . substr($iban, -4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment