I need to create a string which becomes an input to a SHA 256 function to generate its hash equivalent. The string is created by concatenating several variables as below:
String strRequest = "";
strRequest = request_passphrase.concat("access_code=").concat(access_code).concat("amount=").concat(amount).concat("command=").concat(mode).concat("currency=").concat(currency)
.concat("merchant_identifier=").concat(merchant_identifier)
.concat(request_passphrase);
if(strRequest!="" || !strRequest.isEmpty())
{
signature = sha256(strRequest);
}
What should be the best way to create an if-else to drop concatenation for a variable which is null. For ex. if access_code is Null or empty, then the string will be request_passphrase.concat("amount=").concat(amount). and so on.
Aucun commentaire:
Enregistrer un commentaire