文件加密解密算法(Java源码)java,file,算法,加密解密,java源码packagecom.crypto.encrypt;importjava.security.SecureRandom;importjava.io.*;importjavax.crypto.spec.DESKeySpec;importjavax.crypto.SecretKey;importjavax.crypto.SecretKeyFactory;importjavax.crypto.Cipher;importjava.security.InvalidKeyException;importjava.security.NoSuchAlgorithmException;importjava.security.spec.InvalidKeySpecException;importjavax.crypto.NoSuchPaddingException;importjavax.crypto.BadPaddingException;importjavax.crypto.IllegalBlockSizeException;importjava.lang.reflect.Constructor;importjava.security.spec.KeySpec;importjava.lang.reflect.InvocationTargetException;publicclassEncryptData{privateStringkeyfile=null;publicEncryptData(){}publicEncryptData(Stringkeyfile){this.keyfile=keyfile;}/***加密文件*@paramfilenameString源路径*@paramfilenamekeyString加密后的路径*/publicvoidcreateEncryptData(Stringfilename,Stringfilenamekey)throwsIllegalStateException,IllegalBlockSizeException,BadPaddingException,NoSuchPaddingException,InvalidKeySpecException,NoSuchAlgorithmException,InvalidKeyException,IOException,InstantiationException,IllegalAccessException,IllegalArgumentException,InvocationTargetException,NoSuchMethodException,SecurityException,ClassNotFoundException,IllegalStateException,IllegalBlockSizeException,BadPaddingException,NoSuchPaddingException,InvalidKeySpecException,NoSuchAlgorithmException,InvalidKeyException,IOException{//验证keyfileif(keyfile==null||keyfile.equals("")){thrownewNullPointerException("有效的key文件路径");}encryptData(filename,filenamekey);}/***加密类文件*@paramfilenameString原始的类文件*@paramencryptfileString加密后的类文件*@throwsIOException*@throwsInvalidKeyException*@throwsNoSuchAlgorithmException*@throwsInvalidKeySpecException*@throwsNoSuchPaddingException*@thro
1