小编ket*_*tan的帖子

建议Java中的文件加密性能

我正在做一些与文件加密相关的工作.我能够加密/解密文件,但面临一个主要的性能问题.当我只读取/写入700 MB大小的视频文件时,我的代码执行大约27-28 MB/s.但是当我执行加密时(我目前正在使用PBEWithMD5AndDES,我将在稍后更改)代码显示速度为9 MB/s.请告知我在哪里可以改进.

代码段:

    int c = 0, BUF_SIZE = 8192;
    byte[] b = new byte[BUF_SIZE];
    FileInputStream fis;
    DataInputStream dis;
    FileOutputStream fos;
    DataOutputStream dos;
    CipherOutputStream cos;


    try {
        // Create PBE parameter set
        pbeParamSpec = new PBEParameterSpec(salt, iterationCount);

        // Create PBE Cipher
        Cipher pbeCipher = Cipher.getInstance(algorithm);

        // get key
        key = generateKeyFromPassword(password);

        // Initialize PBE Cipher with key and parameters
        pbeCipher.init(Cipher.ENCRYPT_MODE, key, pbeParamSpec);

        fis = new FileInputStream(inFile);
        dis = new DataInputStream(fis);
        fos = new FileOutputStream(outFile);
        dos = new DataOutputStream(fos); …
Run Code Online (Sandbox Code Playgroud)

java encryption performance

6
推荐指数
1
解决办法
3081
查看次数

标签 统计

encryption ×1

java ×1

performance ×1