I have some encrypting (and decrypting) functions that take any int
value and return also any int
value (it uses some xor operations with large prime numbers under the hood):
public interface IIntEncryption {
public int Encrypt(int value);
public int Decrypt(int encryptedValue);
}
Now I want to use it to encrypt string. My idea is to take each char from the string, convert it to int, encrypt with the function above and then convert back to char. The problem is that not every int value is valid character value afaik. So casting int to char won't work. So I am thinking that I will need to convert int to two valid characters somehow and then when decrypting convert each pair of two characters. So basically I am looking for following functions:
public interface IStringEncryption {
public string Encrypt(string str, IIntEncryption intEncryption);
public string Decrypt(string encryptedStr, IIntEncryption intEncryption);
}
I tried many ways but I can't figure out how to encrypt/decrypt array if integers into string representation. Finally I want it to be base64 encoded string.