XOR operation with two strings in java

前端 未结 7 502
有刺的猬
有刺的猬 2020-11-28 05:48

How to do bitwise XOR operation to two strings in java.

相关标签:
7条回答
  • 2020-11-28 06:26

    Assuming (!) the strings are of equal length, why not convert the strings to byte arrays and then XOR the bytes. The resultant byte arrays may be of different lengths too depending on your encoding (e.g. UTF8 will expand to different byte lengths for different characters).

    You should be careful to specify the character encoding to ensure consistent/reliable string/byte conversion.

    0 讨论(0)
提交回复
热议问题