Java String Encrypt encryptBankCardNo(String cardNo)

Here you can find the source of encryptBankCardNo(String cardNo)

Description

encrypt Bank Card No

License

Apache License

Declaration

public static String encryptBankCardNo(String cardNo) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static final int DEFAULT_CARD_NUMBER_DISPLAY_LENGTH = 4;

    public static String encryptBankCardNo(String cardNo) {
        if (cardNo == null || cardNo.length() <= DEFAULT_CARD_NUMBER_DISPLAY_LENGTH) {
            return cardNo;
        }// w w  w.  ja v  a  2s  .  c o  m

        String preStr = cardNo.substring(DEFAULT_CARD_NUMBER_DISPLAY_LENGTH,
                cardNo.length() - DEFAULT_CARD_NUMBER_DISPLAY_LENGTH);
        preStr = preStr.replaceAll(".", "*");
        return cardNo.substring(0, DEFAULT_CARD_NUMBER_DISPLAY_LENGTH).concat(preStr)
                .concat(cardNo.substring(cardNo.length() - DEFAULT_CARD_NUMBER_DISPLAY_LENGTH));
    }
}

Related

  1. Encrypt(String str)
  2. Encrypt(String str, String salt)
  3. encrypt(String string)
  4. encrypt(String string)
  5. encrypt0(final byte[] result)
  6. encryptBankCardNoLast4Bits(String cardNo)
  7. encryptBytes(final byte[] b, final int i)
  8. encryptChar(String caracter, int variable, int indice)
  9. EncryptDecrypt(String value)