0

こんにちは、以下に示すように、ファイルのmd5ハッシュをチェックする(Android)アプリを作成しようとしています。このコードは小さなファイルに対してのみ機能します。誰か助けてもらえますか?

final TextView informations = (TextView) findViewById(R.id.Informations);
            final EditText input = (EditText) findViewById(R.id.ToCrack);
            String filepath = data.getDataString();
            String rawtext;
            String hash;
            StringBuilder text = new StringBuilder();
            filepath = filepath.split("//")[1];
            File file = new File(filepath);
            Toast.makeText(getApplicationContext(),"Loading: "+filepath,Toast.LENGTH_LONG).show();
            FileInputStream fis = null;
            BufferedInputStream bis = null;
            DataInputStream dis = null;
            try{
                fis = new FileInputStream(file);
                bis = new BufferedInputStream(fis);
                dis = new DataInputStream(bis);
                while (dis.available() != 0){
                    text.append(dis.readLine()+"\n");
                }
            }
            catch (IOException e){
                e.printStackTrace();
            }
            finally {
                try{
                    fis.close();
                    bis.close();
                    dis.close();
                }
                catch (IOException ex){
                    ex.printStackTrace();
                }
            }
            rawtext = text.toString().substring(0, text.length()-1);
            hash = new MD5(rawtext).hexdigest();
            if (hash.equals(input.getText().toString())){
                informations.setText("Hash correspond with the file!");
            }
            else{
                informations.setText("File hash= "+hash+"\nHashes does not correspond :(");
            }
            Toast.makeText(getApplicationContext(),"Copied file hash to clipboard.",Toast.LENGTH_LONG).show();
4

1 に答える 1