...

/

Solution Review: Message Encryption

Solution Review: Message Encryption

Have a look at the solution to the 'Message Encryption' challenge.

Rubric criteria

Solution

Press + to interact
class RunEncryption
{
public static void main(String args[])
{
// Encrypting a String
System.out.println(encrypt("hefOP830nskdd0qSW uIm", '0', '.', "tuy83AB9"));
}
// Method to encrypt the string
public static String encrypt(String stringToBeEncrypted, char oldChar, char newChar, String extraString)
{
String str = stringToBeEncrypted.toLowerCase();
String update = str.substring(0, str.length()/2) + extraString + str.substring(str.length()/2);
return update.replace(oldChar, newChar);
}
}

Rubric-wise

...