Андройд простейший шифровщик строк

Делаю простой шифровщик. В ИнтелиджИдее работает с помощью XOR. Все супер. Шифрует строку по заданному ключу. В Андройде не работает. Причем каждый раз шифрует строку по-разному. В ИнтелиджИдее всегда получаю один и тот же результат шифрования.

Моя xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <EditText
        android:id="@+id/enter"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/entertext"/>

    <EditText
        android:id="@+id/key"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/key"/>

    <Button
        android:id="@+id/crypt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="@string/crypt"
        android:onClick="cryptText"/>

    <EditText
        android:id="@+id/result"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>


</LinearLayout>

java code activity

package com.example.cryptapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void cryptText (View view){
        EditText enter = (EditText) findViewById(R.id.enter);
        EditText key = (EditText) findViewById(R.id.key);
        Button crypt = (Button) findViewById(R.id.crypt);
        EditText result = (EditText) findViewById(R.id.result);


        String msg = String.valueOf(enter.getText());
        String myKey = String.valueOf(key.getText());
        byte myByteKey = Byte.parseByte(myKey);
        char[] myArray = msg.toCharArray();

        for (int i = 0; i<myArray.length; i++){
            myArray[i] ^= myByteKey;
        }

        String myCryptString = myArray.toString();
        String myStringOfKey = String.valueOf(myByteKey);
        result.setText(myCryptString);
        

    }

Ответы (1 шт):

Автор решения: Arty Morris

Насколько я помню, getText() даёт идентификатор. Попробуйте

String msg = enter.getText().toString();
→ Ссылка