Program Flow
Sender - Generate encryption key as byte[] and show its Base64.encodeToString
value to the user then sent that byte[] (key) to the Receiver as udp packet
Receiver - Receive UDP packet and get the key (byte[]), and Getting the Key from user as String (user know the string becoz I shown in Sender program) and convert received key (byte[]) to String using Base64.encodeToString
Here is the Problem, when I compare Both String using equals
it return false
When I print both string in logcat
the Output is
12-05 15:39:32.047: V/userkey(2210): oIAfhtGnf+tBX8NBB5ONVQ==
12-05 15:39:32.047: V/reckey(2210): oIAfhtGnf+tBX8NBB5ONVQ==
here you can see both string has same character sequence
Important
I searched lot and coming to know about contentEquals
, I tried this too with hope that it will solve my issue becoz its just compare the characters and sequence of both string,
But I can't get this working, its too returning false for these Strings...
I get the String from user in EditText as
txtDeKey.getText().toString()
and converting byte[] to String as (tried both)
Base64.encodeToString(key1, Base64.DEFAULT).toString()
Base64.encodeToString(key1, Base64.DEFAULT)