M
M
mortdekai2021-11-13 21:01:40
Java
mortdekai, 2021-11-13 21:01:40

How to encode a phrase by aes 256 in java?

How to encode a phrase using aes?
Below is my code

import java.util.Scanner;

public class encrypt {

        public static void main (String[] args){
             Scanner e = new Scanner(System.in);

           String str = e.nextLine();
           String key = e.nextLine();
            byte[] encrypt1 = str.getBytes();
            byte[] encrypt2 = key.getBytes();
            byte[] result = new byte[str.length()];
            
            for (int i = 0; i < encrypt1.length; i++) {
                result[i] = (byte) (encrypt1[i] ^ encrypt2[i % encrypt2.length]);
                System.out.println(result);
            }
            
            }

        }


Whatever I don't encode always produces only this result:
Hello world
112828182
[[email protected]

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
B
BorLaze, 2021-11-13
@BorLaze

Uh-uh... where is aes256?
Here is an encryption example: https://razilov-code.ru/2018/03/16/aes-java/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question