0

I'm developing a system that ask the user to enter text in textarea(plaintext) then it encrypt it using key entered by user in textbox(key). after that it calculate the user input text size, this is how the code is. but in the running time it only show the "yottabytes" in the textarea(size)

byte[] plain = plaintext.getText().getBytes();
byte[] K = key.getText().getBytes();

byte[] encrypted = encrypt(plain, K);
    String a = bytesToHex(encrypted);
    encryptedtext.setText(a);


    String desc[] = new String[]{"bytes ", " kilobytes", " megabytes", " gigabytes", "terabytes", "petabytes", "exabytes", "zettabytes", "yottabytes"};
    String s = plaintext.getText();
    double len = s.length();

    for (String d : desc) {
        size.setText(d + " : " + len);
        len /= 1024;

    }

0 Answers0