I’m trying to making a game where I can type a word into an inputfield and when the L337 toggle is set on, the L337 version of that word comes out the output text, which is pretty much replacing some letters with numbers and other letters. It basically works, but I can’t get the result to be encrypted into L337 form. It just comes out the same way it came in, whether the toggle is on or off. Could someone help me please?
public class Encryption : MonoBehaviour
{
InputField input;
public Text output;
string inputText;
public Toggle L337Toggle;
void Start()
{
L337Toggle.isOn = false;
}
private void Update()
{
inputText = input.text;
output.text = inputText;
var textEncryption = new TextEncryption(inputText);
var L337Encryption = new L337Encryption(textEncryption);
if (Input.GetKeyDown("enter"))
{
if (L337Toggle.isOn == true)
{
string result = L337Encryption.Encrypt();
}
}
}
public interface IEncryption
{
string Encrypt();
}
public class TextEncryption : IEncryption
{
private string originalString;
public TextEncryption(string original)
{
originalString = original;
}
public string Encrypt()
{
Debug.Log("Encrypting Text");
return originalString;
}
}
public class L337Encryption : IEncryption
{
private IEncryption _encryption;
public L337Encryption(IEncryption encryption)
{
_encryption = encryption;
}
public string Encrypt()
{
Debug.Log("Encrypting L337 Text");
string result = _encryption.Encrypt();
result = result.Replace('a', '4').Replace('b', '8').Replace('e', '3').Replace('g', '6').Replace('h', '4').Replace('l', '1')
.Replace('0', '0').Replace('q', '9').Replace('s', '5').Replace('t', '7');
return result;
}
}
}