锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产大陆亚洲精品国产,亚洲一级毛片在线播放,日本红怡院亚洲红怡院最新http://www.tkk7.com/zhaochengming/category/25528.htmlzh-cnWed, 05 Sep 2007 04:38:02 GMTWed, 05 Sep 2007 04:38:02 GMT60瀵規枃浠跺帇緙╁姞瀵?瑙e瘑瑙e帇緙╃殑渚嬪瓙,DES/RSAhttp://www.tkk7.com/zhaochengming/archive/2007/09/03/142396.htmlhelloworld2008helloworld2008Mon, 03 Sep 2007 09:35:00 GMThttp://www.tkk7.com/zhaochengming/archive/2007/09/03/142396.htmlhttp://www.tkk7.com/zhaochengming/comments/142396.htmlhttp://www.tkk7.com/zhaochengming/archive/2007/09/03/142396.html#Feedback0http://www.tkk7.com/zhaochengming/comments/commentRss/142396.htmlhttp://www.tkk7.com/zhaochengming/services/trackbacks/142396.htmlRSA鍘嬬緝鍔犲瘑/瑙e帇緙╄В瀵?/strong>
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.security.Key;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.util.Properties;
import java.util.UUID;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;

import javax.crypto.Cipher;

/**
 * 瀵規枃浠跺帇緙╁姞瀵?瑙e瘑瑙e帇緙?瀵硅薄綾?br />  *
 */
public class ZipEncrypt {
 private static PrivateKey privateKey;
 private static PublicKey publicKey;
 private static void directoryZip(ZipOutputStream out, File f, String base)
   throws Exception {
  // 濡傛灉浼犲叆鐨勬槸鐩綍
  if (f.isDirectory()) {
   File[] fl = f.listFiles();
   // 鍒涘緩鍘嬬緝鐨勫瓙鐩綍
   out.putNextEntry(new ZipEntry(base + "/"));
   if (base.length() == 0) {
    base = "";
   } else {
    base = base + "/";
   }
   for (int i = 0; i < fl.length; i++) {
    directoryZip(out, fl[i], base + fl[i].getName());
   }
  } else {
   // 鎶婂帇緙╂枃浠跺姞鍏ar涓?br />    out.putNextEntry(new ZipEntry(base));
   FileInputStream in = new FileInputStream(f);
   byte[] bb = new byte[2048];
   int aa = 0;
   while ((aa = in.read(bb)) != -1) {
    out.write(bb, 0, aa);
   }
   in.close();
  }
 }

 /**
  * 鍘嬬緝鏂囦歡
  * @param zos
  * @param file
  * @throws Exception
  */
 private static void fileZip(ZipOutputStream zos, File file)
   throws Exception {
  if (file.isFile()) {
   zos.putNextEntry(new ZipEntry(file.getName()));
   FileInputStream fis = new FileInputStream(file);
   byte[] bb = new byte[2048];
   int aa = 0;
   while ((aa = fis.read(bb)) != -1) {
    zos.write(bb, 0, aa);
   }
   fis.close();
   System.out.println(file.getName());
  } else {
   directoryZip(zos, file, "");
  }
 }

 /**
  * 瑙e帇緙╂枃浠?br />   *
  * @param zis
  * @param file
  * @throws Exception
  */
 private static void fileUnZip(ZipInputStream zis, File file)
   throws Exception {
  ZipEntry zip = zis.getNextEntry();
  if (zip == null)
   return;
  String name = zip.getName();
  File f = new File(file.getAbsolutePath() + "/" + name);
  if (zip.isDirectory()) {
   f.mkdirs();
   fileUnZip(zis, file);
  } else {
   f.createNewFile();
   FileOutputStream fos = new FileOutputStream(f);
   byte b[] = new byte[2048];
   int aa = 0;
   while ((aa = zis.read(b)) != -1) {
    fos.write(b, 0, aa);
   }
   fos.close();
   fileUnZip(zis, file);
  }
 }

 /**
  * 瀵筪irectory鐩綍涓嬬殑鏂囦歡鍘嬬緝錛屼繚瀛樹負鎸囧畾鐨勬枃浠秡ipFile
  *
  * @param directory
  * @param zipFile
  */
 private static void zip(String directory, String zipFile) {
  try {
   ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(
     zipFile));
   fileZip(zos, new File(directory));
   zos.close();
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 /**
  * 瑙e帇緙╂枃浠秡ipFile淇濆瓨鍦╠irectory鐩綍涓?br />   *
  * @param directory
  * @param zipFile
  */
 private static void unZip(String directory, String zipFile) {
  try {
   ZipInputStream zis = new ZipInputStream(
     new FileInputStream(zipFile));
   File f = new File(directory);
   f.mkdirs();
   fileUnZip(zis, f);
   zis.close();
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 /**
  * 鏍規嵁key鐨勮礬寰勬枃浠惰幏寰楁寔涔呭寲鎴愭枃浠剁殑key
  * <P>
  * 渚嬪瓙: RsaEncrypt.getKey("c:/systemkey/private.key");
  *
  * @param keyPath
  * @return
  */
 public static Key getKey(String keyPath) throws Exception {
  Key key = null;
  FileInputStream fis = new FileInputStream(keyPath);
  ObjectInputStream ofs = new ObjectInputStream(fis);
  key = (Key) ofs.readObject();
  return key;
 }

 /**
  * 鎶婃枃浠秙rcFile鍔犲瘑鍚庡瓨鍌ㄤ負destFile
  *
  * @param srcFile
  * @param destFile
  */
 private static void encrypt(String srcFile, String destFile, Key privateKey)
   throws Exception {
  Cipher cipher = Cipher.getInstance("RSA");
  cipher.init(Cipher.ENCRYPT_MODE, privateKey);
  FileInputStream fis = new FileInputStream(srcFile);
  FileOutputStream fos = new FileOutputStream(destFile);
  byte[] b = new byte[53];
  while (fis.read(b) != -1) {
   fos.write(cipher.doFinal(b));
  }
  fos.close();
  fis.close();
 }

 /**
  * 鎶婃枃浠秙rcFile瑙e瘑鍚庡瓨鍌ㄤ負destFile
  *
  * @param srcFile
  * @param destFile
  * @param privateKey
  * @throws Exception
  */
 private static void decrypt(String srcFile, String destFile, Key privateKey)
   throws Exception {
  Cipher cipher = Cipher.getInstance("RSA");
  cipher.init(Cipher.DECRYPT_MODE, privateKey);
  FileInputStream fis = new FileInputStream(srcFile);
  FileOutputStream fos = new FileOutputStream(destFile);
  byte[] b = new byte[64];
  while (fis.read(b) != -1) {
   fos.write(cipher.doFinal(b));
  }
  fos.close();
  fis.close();
 }

 /**
  * 瀵圭洰褰晄rcFile涓嬬殑鎵鏈夋枃浠剁洰褰曡繘琛屽厛鍘嬬緝鍚庢搷浣?鐒跺悗淇濆瓨涓篸estfile
  *
  * @param srcFile
  *            瑕佹搷浣滅殑鐩綍 濡俢:/test/test
  * @param destfile
  *            鍘嬬緝鍔犲瘑鍚庡瓨鏀劇殑鏂囦歡鍚?濡俢:/鍔犲瘑鍘嬬緝鏂囦歡.zip
  * @param keyfile
  *            鍏挜瀛樻斁鍦扮偣
  */
 public static void encryptZip(String srcFile, String destfile, String keyfile) throws Exception {
  SecureRandom sr = new SecureRandom();
  KeyPairGenerator kg = KeyPairGenerator.getInstance("RSA");
  kg.initialize(512, sr);
  //浜х敓鏂板瘑閽ュ
  KeyPair kp = kg.generateKeyPair();
  //鑾峰緱縐佸寵
  ZipEncrypt.privateKey = kp.getPrivate();
  //鑾峰緱鍏挜
  ZipEncrypt.publicKey = kp.getPublic();
  File f = new File(keyfile);
  f.createNewFile();
  FileOutputStream fos = new FileOutputStream(f);
  ObjectOutputStream dos = new ObjectOutputStream(fos);
  dos.writeObject(ZipEncrypt.publicKey);
  
  File temp = new File(UUID.randomUUID().toString() + ".zip");
  temp.deleteOnExit();
  // 鍏堝帇緙╂枃浠?br />   zip(srcFile, temp.getAbsolutePath());
  // 瀵規枃浠跺姞瀵?br />   encrypt(temp.getAbsolutePath(), destfile, privateKey);
  temp.delete();
 }

 /**
  * 瀵規枃浠秙rcfile榪涜鍏堣В瀵嗗悗瑙e帇緙?鐒跺悗瑙e帇緙╁埌鐩綍destfile涓?br />   *
  * @param srcfile
  *            瑕佽В瀵嗗拰瑙e帇緙╃殑鏂囦歡鍚?濡俢:/鐩爣.zip
  * @param destfile
  *            瑙e帇緙╁悗鐨勭洰褰?濡俢:/abc
  * @param publicKey
  *            鍏挜
  */
 public static void decryptUnzip(String srcfile, String destfile,
   Key publicKey) throws Exception {
  // 鍏堝鏂囦歡瑙e瘑
  File temp = new File(UUID.randomUUID().toString() + ".zip");
  temp.deleteOnExit();
  decrypt(srcfile, temp.getAbsolutePath(), publicKey);
  // 瑙e帇緙?br />   unZip(destfile, temp.getAbsolutePath());
  temp.delete();
 }

 public static void main(String args[]) throws Exception { 
  File f = new File(".");
  Properties prop = new Properties(); ;
  FileInputStream fis = new FileInputStream("./conf.properties");
  prop.load(fis);
  //瑕佸帇緙╃殑鐩綍
  String srcPath = prop.getProperty("SRC_PATH");
  //鍘嬬緝鍚庣殑瀛樻斁鏂囦歡
  String destZip = prop.getProperty("DEST_FILE");
  //鍘嬬緝鍔犲瘑鍚庣殑publickey
  String keyfile = prop.getProperty("KEY_FILE");
  ZipEncrypt.encryptZip(srcPath, destZip,keyfile);
  
  /*瑙e瘑
  ZipEncrypt.decryptUnzip("e:/comXXX/comxxxx.zip", "d:/comxxx", ZipEncrypt
    .getKey("e:/comXXX/public.key"));
  */
 }
}




 

 

AES鍘嬬緝鍔犲瘑/瑙e帇緙╄В瀵嗭紝緗戜笂涓鑸敤base64鏉ュbyte[]緙栫爜,鍏跺疄涓嶉渶瑕侊紝鎸囧畾AES/CBC/PKCS5Padding
鏉ユ寚瀹氬姞瀵嗚В瀵嗘椂鍊欎綅鏁頒笉瀵圭殑鎯呭喌涓嬶紝鐢╬kcs5padding鏉ラ檮鍔犱綅鏁幫紝涓嶈繃榪欎釜鏃跺欒瑙e瘑鐨勬枃浠剁殑鏃跺欙紝瑕佸璇?6浣嶇殑楠岃瘉浣嶅氨涓嶄細鎶ュ紓甯?br />
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.security.Key;
import java.security.SecureRandom;
import java.util.UUID;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

/**
 * 瀵規枃浠跺姞瀵?瑙e瘑鍜屽帇緙?瑙e帇緙╁璞$被
 * @author 璧墊垚鏄?br />  */
public class ZipEncrypt {
        private  void directoryZip(ZipOutputStream out, File f, String base)
                        throws Exception {
                // 濡傛灉浼犲叆鐨勬槸鐩綍
            if (f.isDirectory()) {
                File[] fl = f.listFiles();
                // 鍒涘緩鍘嬬緝鐨勫瓙鐩綍
                out.putNextEntry(new ZipEntry(base + "/"));
                if (base.length() == 0) {
                    base = "";
                } else {
                    base = base + "/";
                }
                for (int i = 0; i < fl.length; i++) {
                    directoryZip(out, fl[i], base + fl[i].getName());
                }
            } else {
                    // 鎶婂帇緙╂枃浠跺姞鍏ar涓?br />                 out.putNextEntry(new ZipEntry(base));
                FileInputStream in = new FileInputStream(f);
                byte[] bb = new byte[2048];
                int aa = 0;
                while ((aa = in.read(bb)) != -1) {
                        out.write(bb, 0, aa);
                }
                in.close();
            }
        }

        /**
         * 鍘嬬緝鏂囦歡
         * @param zos
         * @param file
         * @throws Exception
         */
        private void fileZip(ZipOutputStream zos, File file)
                        throws Exception {
            if (file.isFile()) {
                zos.putNextEntry(new ZipEntry(file.getName()));
                FileInputStream fis = new FileInputStream(file);
                byte[] bb = new byte[2048];
                int aa = 0;
                while ((aa = fis.read(bb)) != -1) {
                        zos.write(bb, 0, aa);
                }
                fis.close();
                System.out.println(file.getName());
            } else {
                directoryZip(zos, file, "");
            }
        }

        /**
         * 瑙e帇緙╂枃浠?br />          *
         * @param zis
         * @param file
         * @throws Exception
         */
        private void fileUnZip(ZipInputStream zis, File file)
                        throws Exception {
            ZipEntry zip = zis.getNextEntry();
            if (zip == null)
                return;
            String name = zip.getName();
            File f = new File(file.getAbsolutePath() + "/" + name);
            if (zip.isDirectory()) {
                f.mkdirs();
                fileUnZip(zis, file);
            } else {
                f.createNewFile();
                FileOutputStream fos = new FileOutputStream(f);
                byte b[] = new byte[2048];
                int aa = 0;
                while ((aa = zis.read(b)) != -1) {
                    fos.write(b, 0, aa);
                }
                fos.close();
                fileUnZip(zis, file);
            }
        }

        /**
         * 瀵筪irectory鐩綍涓嬬殑鏂囦歡鍘嬬緝錛屼繚瀛樹負鎸囧畾鐨勬枃浠秡ipFile
         *
         * @param directory
         * @param zipFile
         */
        private void zip(String directory, String zipFile) {
            try {
                ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(
                                zipFile));
                fileZip(zos, new File(directory));
                zos.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        /**
         * 瑙e帇緙╂枃浠秡ipFile淇濆瓨鍦╠irectory鐩綍涓?br />          *
         * @param directory
         * @param zipFile
         */
        private void unZip(String directory, String zipFile) {
            try {
                ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile));
                File f = new File(directory);
                f.mkdirs();
                fileUnZip(zis, f);
                zis.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        /**
         * 鏍規嵁key鐨勮礬寰勬枃浠惰幏寰楁寔涔呭寲鎴愭枃浠剁殑key
         * <P>
         * 渚嬪瓙: RsaEncrypt.getKey("c:/systemkey/private.key");
         *
         * @param keyPath
         * @return
         */
        private Key getKey(String keyPath) throws Exception {
            FileInputStream fis = new FileInputStream(keyPath);
            byte[] b = new byte[16];
            fis.read(b);
            SecretKeySpec dks = new SecretKeySpec(b,"AES");
            fis.close();
            return dks;
        }

        /**
         * 鎶婃枃浠秙rcFile鍔犲瘑鍚庡瓨鍌ㄤ負destFile
         *
         * @param srcFile
         * @param destFile
         */
        private void encrypt(String srcFile, String destFile, Key privateKey)
                        throws Exception {
         SecureRandom sr = new SecureRandom();
            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
            IvParameterSpec spec=new IvParameterSpec(privateKey.getEncoded());
            cipher.init(Cipher.ENCRYPT_MODE, privateKey,spec,sr);
            FileInputStream fis = new FileInputStream(srcFile);
            FileOutputStream fos = new FileOutputStream(destFile);
            byte[] b = new byte[2048];
            while (fis.read(b) != -1) {
                fos.write(cipher.doFinal(b));
            }
            fos.close();
            fis.close();
        }

        /**
         * 鎶婃枃浠秙rcFile瑙e瘑鍚庡瓨鍌ㄤ負destFile
         *
         * @param srcFile
         * @param destFile
         * @param privateKey
         * @throws Exception
         */
        private void decrypt(String srcFile, String destFile, Key privateKey)
                        throws Exception {
   SecureRandom sr = new SecureRandom();
         Cipher ciphers = Cipher.getInstance("AES/CBC/PKCS5Padding");
         IvParameterSpec spec=new IvParameterSpec(privateKey.getEncoded());
         ciphers.init(Cipher.DECRYPT_MODE,privateKey,spec,sr);  
            FileInputStream fis = new FileInputStream(srcFile);
            FileOutputStream fos = new FileOutputStream(destFile); 
            byte[] b = new byte[2064];
            while (fis.read(b) != -1) {                 
                fos.write(ciphers.doFinal(b));
            }
            fos.close();
            fis.close();
        }

        /**
         * 瀵圭洰褰晄rcFile涓嬬殑鎵鏈夋枃浠剁洰褰曡繘琛屽厛鍘嬬緝鍚庢搷浣?鐒跺悗淇濆瓨涓篸estfile
         *
         * @param srcFile
         *            瑕佹搷浣滅殑鐩綍 濡俢:/test/test
         * @param destfile
         *            鍘嬬緝鍔犲瘑鍚庡瓨鏀劇殑鏂囦歡鍚?濡俢:/鍔犲瘑鍘嬬緝鏂囦歡.zip
         * @param keyfile
         *            鍏挜瀛樻斁鍦扮偣
         */
        public void encryptZip(String srcFile, String destfile, String keyfile) throws Exception {
            SecureRandom sr = new SecureRandom();
            KeyGenerator  kg = KeyGenerator.getInstance("AES");
            kg.init(128,sr);
            SecretKey key = kg.generateKey();
            File f = new File(keyfile);
            if (!f.getParentFile().exists())
             f.getParentFile().mkdirs();
            f.createNewFile();
            FileOutputStream fos = new FileOutputStream(f);
            fos.write(key.getEncoded());
            File temp = new File(UUID.randomUUID().toString() + ".zip");
            temp.deleteOnExit();
            // 鍏堝帇緙╂枃浠?br />             zip(srcFile, temp.getAbsolutePath());
            // 瀵規枃浠跺姞瀵?br />             encrypt(temp.getAbsolutePath(), destfile, key);
            temp.delete();
        }

        /**
         * 瀵規枃浠秙rcfile榪涜鍏堣В瀵嗗悗瑙e帇緙?鐒跺悗瑙e帇緙╁埌鐩綍destfile涓?br />          *
         * @param srcfile
         *            瑕佽В瀵嗗拰瑙e帇緙╃殑鏂囦歡鍚?濡俢:/鐩爣.zip
         * @param destfile
         *            瑙e帇緙╁悗鐨勭洰褰?濡俢:/abc
         * @param publicKey
         *            鍏挜
         */
        public void decryptUnzip(String srcfile, String destfile,
                        String keyfile) throws Exception {
            // 鍏堝鏂囦歡瑙e瘑
            File temp = new File(UUID.randomUUID().toString() + ".zip");
            temp.deleteOnExit();
            decrypt(srcfile, temp.getAbsolutePath(), this.getKey(keyfile));
            // 瑙e帇緙?br />             unZip(destfile, temp.getAbsolutePath());
            temp.delete();
        }

        public static void main(String args[]) throws Exception {
      long a = System.currentTimeMillis();
            new ZipEncrypt().encryptZip("e:/com", "e:/comXXX/page.zip","e:/comXXX/public.key");
           
            System.out.println(System.currentTimeMillis()-a);
            a = System.currentTimeMillis();
           
            new ZipEncrypt().decryptUnzip("e:/comXXX/page.zip", "e:/comxxx", "e:/comXXX/public.key");
            System.out.println(System.currentTimeMillis()-a);
        }
}



]]>
ras 鍔犲瘑http://www.tkk7.com/zhaochengming/archive/2007/09/03/142223.htmlhelloworld2008helloworld2008Mon, 03 Sep 2007 02:43:00 GMThttp://www.tkk7.com/zhaochengming/archive/2007/09/03/142223.htmlhttp://www.tkk7.com/zhaochengming/comments/142223.htmlhttp://www.tkk7.com/zhaochengming/archive/2007/09/03/142223.html#Feedback0http://www.tkk7.com/zhaochengming/comments/commentRss/142223.htmlhttp://www.tkk7.com/zhaochengming/services/trackbacks/142223.htmlimport java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;

import javax.crypto.Cipher;

public class RsaTest {
 public static void main(String args[]) throws Exception {
  SecureRandom sr = new SecureRandom();
  KeyPairGenerator kg = KeyPairGenerator.getInstance("RSA");
  kg.initialize(512, sr);

  //浜х敓鏂板瘑閽ュ
  KeyPair kp = kg.generateKeyPair();
  //鑾峰緱縐佸寵
  PrivateKey prk = kp.getPrivate();
  //鑾峰緱鍏挜
  PublicKey puk = kp.getPublic();
  
  String str = "浣犲ソ鍚?鎴戝湪嫻嬭瘯RSA嫻嬭瘯^_^";
  Cipher cipher = Cipher.getInstance("RSA");
  cipher.init(Cipher.ENCRYPT_MODE, prk);
  byte[] dest = cipher.doFinal(str.getBytes());
  System.out.println(new String(dest));
  
  
  Cipher ciphers = Cipher.getInstance("RSA");
  ciphers.init(Cipher.DECRYPT_MODE,puk);  
  byte[] srcs = ciphers.doFinal(dest);
  System.out.println("瑙e瘑鍚庣殑鏁版嵁:"+new String(srcs));
  
  
 }
}



]]>
java jca des 鏁板瓧絳懼悕http://www.tkk7.com/zhaochengming/archive/2007/09/03/142210.htmlhelloworld2008helloworld2008Mon, 03 Sep 2007 02:20:00 GMThttp://www.tkk7.com/zhaochengming/archive/2007/09/03/142210.htmlhttp://www.tkk7.com/zhaochengming/comments/142210.htmlhttp://www.tkk7.com/zhaochengming/archive/2007/09/03/142210.html#Feedback0http://www.tkk7.com/zhaochengming/comments/commentRss/142210.htmlhttp://www.tkk7.com/zhaochengming/services/trackbacks/142210.htmlimport java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.Signature;

public class RsaTest {
 public static void main(String args[]) throws Exception {
  SecureRandom sr = new SecureRandom();
  KeyPairGenerator kg = KeyPairGenerator.getInstance("DSA");
  kg.initialize(512, sr);

  //浜х敓鏂板瘑閽ュ
  KeyPair kp = kg.generateKeyPair();
  //鑾峰緱縐佸寵
  PrivateKey prk = kp.getPrivate();
  //鑾峰緱鍏挜
  PublicKey puk = kp.getPublic();
  //榪斿洖涓涓寚瀹氱畻娉曠殑Signature瀵硅薄
  Signature signature = Signature.getInstance("DSA");
  signature.initSign(prk);
  String str = "浣犲ソ鍚?鎴戝湪嫻嬭瘯RSA嫻嬭瘯^_^浣犲ソ鍚?鎴戝湪嫻嬭瘯RSA嫻嬭瘯^_^浣犲ソ鍚?鎴戝湪嫻嬭瘯RSA嫻嬭瘯^_^浣犲ソ鍚?鎴戝湪嫻嬭瘯RSA嫻嬭瘯^_^";
  signature.update(str.getBytes());
  byte[] dest = signature.sign();
  System.out.println("Enc:"+new String(dest));
  
  Signature signature2 = Signature.getInstance("DSA");
  signature2.initVerify(puk);
  signature2.update(str.getBytes());
  System.out.println(signature2.verify(dest));
 }
}



]]>
jca des鍔犲瘑綆鍗曚緥瀛?/title><link>http://www.tkk7.com/zhaochengming/archive/2007/09/03/142191.html</link><dc:creator>helloworld2008</dc:creator><author>helloworld2008</author><pubDate>Mon, 03 Sep 2007 01:29:00 GMT</pubDate><guid>http://www.tkk7.com/zhaochengming/archive/2007/09/03/142191.html</guid><wfw:comment>http://www.tkk7.com/zhaochengming/comments/142191.html</wfw:comment><comments>http://www.tkk7.com/zhaochengming/archive/2007/09/03/142191.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/zhaochengming/comments/commentRss/142191.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/zhaochengming/services/trackbacks/142191.html</trackback:ping><description><![CDATA[<p>import java.security.SecureRandom;</p> <p>import javax.crypto.Cipher;<br /> import javax.crypto.KeyGenerator;<br /> import javax.crypto.SecretKey;<br /> import javax.crypto.SecretKeyFactory;<br /> import javax.crypto.spec.DESKeySpec;</p> <p>public class JcaTest {<br />  public static void main(String args[]) throws Exception {<br />   SecureRandom sr = new SecureRandom();<br />   KeyGenerator kg = KeyGenerator.getInstance("DES");<br />   kg.init(sr);<br />   SecretKey key = kg.generateKey();<br />   // 鑾峰緱瀵嗗寵鏁版嵁<br />   byte rawKeyData[] = key.getEncoded();<br />   Cipher cipher = Cipher.getInstance("DES");<br />   cipher.init(Cipher.ENCRYPT_MODE, key, sr);</p> <p>  String src = "浣犲ソ鍚楁祴璇曞姞瀵?;<br />   byte[] dest = cipher.doFinal(src.getBytes());<br />   System.out.println("鍔犲瘑鍚庣殑鏁版嵁:"+new String(dest));</p> <p>  // 瑙e瘑 浠庡師濮嬪瘑鍖欐暟鎹垱寤轟竴涓狣ESKeySpec瀵硅薄<br />   sr = new SecureRandom();<br />   DESKeySpec dks = new DESKeySpec(rawKeyData);<br />   SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");<br />   SecretKey keys = keyFactory.generateSecret(dks);<br />   Cipher ciphers = Cipher.getInstance("DES");<br />   ciphers.init(   Cipher.DECRYPT_MODE,keys,sr);   <br />   byte[] srcs = ciphers.doFinal(dest);<br />   System.out.println("瑙e瘑鍚庣殑鏁版嵁:"+new String(srcs));<br />  }<br /> }<br /> </p> <img src ="http://www.tkk7.com/zhaochengming/aggbug/142191.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/zhaochengming/" target="_blank">helloworld2008</a> 2007-09-03 09:29 <a href="http://www.tkk7.com/zhaochengming/archive/2007/09/03/142191.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://777cc55.com" target="_blank">久久精品无码精品免费专区</a>| <a href="http://jjv5.com" target="_blank">亚洲国产乱码最新视频</a>| <a href="http://spvec.com" target="_blank">美女扒开屁股让男人桶爽免费</a>| <a href="http://hzsprfm.com" target="_blank">黄色一级毛片免费</a>| <a href="http://kwknc.com" target="_blank">国产成人免费高清在线观看</a>| <a href="http://yuntao360.com" target="_blank">亚洲乱码无限2021芒果</a>| <a href="http://www-79983.com" target="_blank">91黑丝国产线观看免费</a>| <a href="http://117949b.com" target="_blank">成人免费视频试看120秒</a>| <a href="http://www045888.com" target="_blank">亚洲精品视频在线观看你懂的</a>| <a href="http://www-kj5799.com" target="_blank">亚洲成av人片在线天堂无</a>| <a href="http://mabaolu.com" target="_blank">eeuss影院免费92242部</a>| <a href="http://1314xxx.com" target="_blank">久久精品国产亚洲5555</a>| <a href="http://khushkhush.com" target="_blank">国产精品一区二区三区免费</a>| <a href="http://1777000.com" target="_blank">亚洲色偷偷综合亚洲AVYP</a>| <a href="http://222941.com" target="_blank">热99RE久久精品这里都是精品免费</a>| <a href="http://pchbgs.com" target="_blank">亚洲欭美日韩颜射在线二</a>| <a href="http://chinahongfeng.com" target="_blank">伊人久久大香线蕉免费视频</a>| <a href="http://gttest5.com" target="_blank">免费很黄很色裸乳在线观看</a>| <a href="http://caocl1024liu.com" target="_blank">亚洲精彩视频在线观看</a>| <a href="http://ju7776.com" target="_blank">精品无码AV无码免费专区</a>| <a href="http://hhrrrr.com" target="_blank">亚洲午夜成激人情在线影院</a>| <a href="http://ganbadei.com" target="_blank">在线成人a毛片免费播放</a>| <a href="http://cjfuli.com" target="_blank">国产亚洲蜜芽精品久久</a>| <a href="http://079566.com" target="_blank">国产亚洲精品成人AA片新蒲金</a>| <a href="http://gdjiayou.com" target="_blank">a级成人毛片免费视频高清</a>| <a href="http://nkldj.com" target="_blank">91亚洲导航深夜福利</a>| <a href="http://cnpc1002.com" target="_blank">国产精品久久久久免费a∨</a>| <a href="http://ipx588.com" target="_blank">99亚洲乱人伦aⅴ精品</a>| <a href="http://szicon.com" target="_blank">亚洲无人区一区二区三区</a>| <a href="http://91haikala.com" target="_blank">无码日韩精品一区二区三区免费</a>| <a href="http://dangyuming.com" target="_blank">久久综合亚洲色HEZYO社区</a>| <a href="http://ccc321.com" target="_blank">性盈盈影院免费视频观看在线一区</a>| <a href="http://srztw.com" target="_blank">国产午夜亚洲精品不卡免下载</a>| <a href="http://yinyinai155.com" target="_blank">亚洲开心婷婷中文字幕</a>| <a href="http://ittenyear.com" target="_blank">久久精品免费一区二区</a>| <a href="http://jx-dirui.com" target="_blank">国产精品观看在线亚洲人成网</a>| <a href="http://8mav938.com" target="_blank">亚洲色自偷自拍另类小说</a>| <a href="http://igo98.com" target="_blank">久久这里只有精品国产免费10</a>| <a href="http://zhidianzh.com" target="_blank">免费在线观看亚洲</a>| <a href="http://thinkchating.com" target="_blank">亚洲第一视频网站</a>| <a href="http://gzmcmy.com" target="_blank">在线永久免费观看黄网站</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>