Mask certain words

Source: Internet
Author: User

 

Common Methods for summarizing development projects:

 

/**
* Transaction Password Authentication
* @ Param paypwd
* @ Return
*/
Public static string hidepaypwdcode (string paypwd ){
If (null = paypwd) return NULL;
Return getstats (paypwd. Length ());
}

/**
* Log on to the MIIT website
* @ Param loginpwd
* @ Return
*/
Public static string hideloginpwdcode (string loginpwd ){
If (null = loginpwd) return NULL;
Return getstats (loginpwd. Length ());
}


/**
* Merge rows
* @ Param bankaccount
* @ Return
* @ Throws exception
*/
Public static string hideacccode (string acccode ){
If (acccode = NULL) Return "";
Int Len = acccode. Trim (). Length ();
If (LEN = 0) Return "";
String strres = acccode. Trim ();
If (LEN> = 6)
Strres = acccode. Trim (). substring (0, 6 );
String strend = "";
If (LEN> 3)
Strend = acccode. Trim (). substring (len-3 );
Strres + = getstats (len-9) + strend;
Return strres;
}

/**
* Credit Card Renewal Fee
* @ Param phone
* @ Return
*/
Public static string hidecardcode (string cardNumber ){
If (cardNumber = NULL) Return "";
Int Len = cardNumber. Trim (). Length ();
If (LEN = 0) Return "";
String strres = cardNumber. Trim ();
If (LEN> = 8)
Strres = cardNumber. Trim (). substring (0, 8 );
String strend = "";
If (LEN> 4)
Strend = cardNumber. Trim (). substring (len-4 );
Strres + = getstats (len-12) + strend;
Return strres;
}

/**
* Authentication token used
* @ Param personid
* @ Return
*/
Public static string hidepersonidcode (string personid ){
If (personid = NULL) Return "";
Int Len = personid. Trim (). Length ();
If (LEN = 0) Return "";
String strres = personid. Trim ();
If (LEN> = 7)
Strres = personid. Trim (). substring (0, 7 );
Strres + = getstats (len-7 );
Return strres;
}

/**
* Name
* @ Param Username
* @ Return
* @ Throws exception
*/
Public static string hideusername (string username ){
If (username = NULL) Return "";
Int Len = username. Trim (). Length ();
If (LEN = 0) Return "";
String strres = username. Trim ();
If (LEN> = 1)
Strres = username. Trim (). substring (0, 1 );
Strres + = getstats (len-1 );
Return strres;
}

/**
* Residential IP Address
* @ Param addrcode
* @ Return
*/
Public static string hideaddresscode (string address ){
If (address = NULL) Return "";
Int Len = address. Trim (). Length ();
If (LEN = 0) Return "";
String strres = address. Trim ();
If (LEN> = 6)
Strres = address. Trim (). substring (0, 6 );
Strres + = getstats (len-6 );
Return strres;
}

/**
* Email address
* @ Param Username
* @ Return
* @ Throws exception
*/
Public static string hideemailaddress (string emailaddress ){
If (emailaddress = NULL) Return "";
Int Len = emailaddress. Trim (). Length ();
If (LEN = 0) Return "";
String [] aryemail = emailaddress. Split ("@");
String strres = "";
Len = aryemail [0]. Trim (). Length ();
If (LEN> 3)
Strres = aryemail [0]. Trim (). substring (0, len-3 );
Strres + = getstats (3 );
If (aryemail. length> 1)
Strres + = "@" + aryemail [1];
Return strres;
}

/**
* Telephone Hotline
* @ Param phonenumber
* @ Return
* @ Throws exception
*/
Public static string hidephonecode (string phonenumber ){
If (phonenumber = NULL) Return "";
Int Len = phonenumber. Trim (). Length ();
If (LEN = 0) Return "";
String strres = phonenumber. Trim ();
If (LEN> = 5)
Strres = phonenumber. Trim (). substring (0, 5 );
String strend = "";
If (LEN> 2)
Strend = phonenumber. Trim (). substring (len-2 );
Strres + = getstats (len-7) + strend;
Return strres;
}
/**
* Birthday
* @ Param Username
* @ Return
* @ Throws exception
*/
Public static string hidebirthday (integer birthday ){
If (Birthday = NULL) Return "";
Int Len = birthday. tostring (). Trim (). Length ();
If (LEN = 0) Return "";
String strres = birthday. tostring (). Trim ();
If (LEN> = 6)
Strres = birthday. tostring (). Trim (). substring (0, 6 );
Strres + = getstats (len-6 );
Return strres;
}

Private Static string getstats (INT Len ){
If (LEN <= 0) Return "";
String strres = "";
For (INT I = 0; I <Len; I ++)
Strres + = "*";
Return strres;
}

Mask certain words

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.