search

Home  >  Q&A  >  body text

aes - Java使用对称加密算法加密大文件内存资源消耗问题

ringa_leeringa_lee2770 days ago729

reply all(1)I'll reply

  • 阿神

    阿神2017-04-18 10:42:05

    Use CipherOutputStream

    Cipher cipher = Cipher.getInstance("AES");
    cipher.init(Cipher.ENCRYPT_MODE, key);
    
    InputStream is = new FileInputStream(file);  
    CipherOutputStream out = new CipherOutputStream(new FileOutputStream(dest), cipher)
    
    IOUtils.copyLarge(is, out);
    

    reply
    0
  • Cancelreply