锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产大陆亚洲精品国产,亚洲一级毛片在线播放,日本红怡院亚洲红怡院最新http://m.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://m.tkk7.com/zhaochengming/archive/2007/09/03/142396.htmlhelloworld2008helloworld2008Mon, 03 Sep 2007 09:35:00 GMThttp://m.tkk7.com/zhaochengming/archive/2007/09/03/142396.htmlhttp://m.tkk7.com/zhaochengming/comments/142396.htmlhttp://m.tkk7.com/zhaochengming/archive/2007/09/03/142396.html#Feedback0http://m.tkk7.com/zhaochengming/comments/commentRss/142396.htmlhttp://m.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://m.tkk7.com/zhaochengming/archive/2007/09/03/142223.htmlhelloworld2008helloworld2008Mon, 03 Sep 2007 02:43:00 GMThttp://m.tkk7.com/zhaochengming/archive/2007/09/03/142223.htmlhttp://m.tkk7.com/zhaochengming/comments/142223.htmlhttp://m.tkk7.com/zhaochengming/archive/2007/09/03/142223.html#Feedback0http://m.tkk7.com/zhaochengming/comments/commentRss/142223.htmlhttp://m.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://m.tkk7.com/zhaochengming/archive/2007/09/03/142210.htmlhelloworld2008helloworld2008Mon, 03 Sep 2007 02:20:00 GMThttp://m.tkk7.com/zhaochengming/archive/2007/09/03/142210.htmlhttp://m.tkk7.com/zhaochengming/comments/142210.htmlhttp://m.tkk7.com/zhaochengming/archive/2007/09/03/142210.html#Feedback0http://m.tkk7.com/zhaochengming/comments/commentRss/142210.htmlhttp://m.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://m.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://m.tkk7.com/zhaochengming/archive/2007/09/03/142191.html</guid><wfw:comment>http://m.tkk7.com/zhaochengming/comments/142191.html</wfw:comment><comments>http://m.tkk7.com/zhaochengming/archive/2007/09/03/142191.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/zhaochengming/comments/commentRss/142191.html</wfw:commentRss><trackback:ping>http://m.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://m.tkk7.com/zhaochengming/aggbug/142191.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/zhaochengming/" target="_blank">helloworld2008</a> 2007-09-03 09:29 <a href="http://m.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://m.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://socgl.com" target="_blank">亚洲国产成人久久精品99 </a>| <a href="http://ldcatv.com" target="_blank">亚洲国产精品无码久久</a>| <a href="http://wwwav800.com" target="_blank">理论亚洲区美一区二区三区</a>| <a href="http://xxxxcccc.com" target="_blank">亚洲免费视频播放</a>| <a href="http://1444000.com" target="_blank">久久精品亚洲一区二区三区浴池</a>| <a href="http://sdzntg.com" target="_blank">亚洲欧洲专线一区</a>| <a href="http://sxgzjssb.com" target="_blank">欧洲美熟女乱又伦免费视频</a>| <a href="http://fholaer.com" target="_blank">亚洲成a人片在线观看天堂无码</a>| <a href="http://www-7479.com" target="_blank">成全视频免费观看在线看</a>| <a href="http://1444000.com" target="_blank">久久夜色精品国产亚洲av</a>| <a href="http://www-095666.com" target="_blank">成人毛片100免费观看</a>| <a href="http://wuhhz.com" target="_blank">亚洲AV无码成人精品区在线观看 </a>| <a href="http://9haolc.com" target="_blank">亚洲综合色在线观看亚洲</a>| <a href="http://gdfcjzx.com" target="_blank">免费人成大片在线观看播放电影 </a>| <a href="http://343dd.com" target="_blank">xxxx日本免费</a>| <a href="http://kkxzz.com" target="_blank">亚洲Av高清一区二区三区</a>| <a href="http://abab14.com" target="_blank">成年女人午夜毛片免费看</a>| <a href="http://anhuish.com" target="_blank">亚洲av无码兔费综合</a>| <a href="http://wwyw99977.com" target="_blank">亚洲成AⅤ人影院在线观看</a>| <a href="http://fenglufzjx.com" target="_blank">亚洲黄片手机免费观看</a>| <a href="http://cn-taoqigui.com" target="_blank">国产AV无码专区亚洲AV男同</a>| <a href="http://gzweida88.com" target="_blank">国产精品亚洲五月天高清</a>| <a href="http://se969.com" target="_blank">亚洲国产精品不卡毛片a在线</a>| <a href="http://yongyihongze.com" target="_blank">亚洲香蕉久久一区二区三区四区</a>| <a href="http://aqd1987.com" target="_blank">国产精品hd免费观看</a>| <a href="http://89895cc.com" target="_blank">日韩成全视频观看免费观看高清 </a>| <a href="http://gzmkqp.com" target="_blank">亚洲人成图片网站</a>| <a href="http://bqjonline.com" target="_blank">baoyu777永久免费视频</a>| <a href="http://jack-fx.com" target="_blank">免费理论片51人人看电影</a>| <a href="http://conghui8.com" target="_blank">视频一区在线免费观看</a>| <a href="http://caita88.com" target="_blank">亚洲人成色77777</a>| <a href="http://zz1965.com" target="_blank">一级人做人a爰免费视频</a>| <a href="http://66h99.com" target="_blank">久久精品国产亚洲香蕉</a>| <a href="http://dddd20.com" target="_blank">最新仑乱免费视频</a>| <a href="http://yunyitai.com" target="_blank">一级毛片在播放免费</a>| <a href="http://011107.com" target="_blank">免费国产不卡午夜福在线</a>| <a href="http://ncmyw.com" target="_blank">亚洲国产成+人+综合</a>| <a href="http://ymiwang.com" target="_blank">四虎永久在线精品免费影视 </a>| <a href="http://scdsrq.com" target="_blank">亚洲影视自拍揄拍愉拍</a>| <a href="http://8123pp.com" target="_blank">国产免费69成人精品视频</a>| <a href="http://zj1069.com" target="_blank">亚洲日韩AV一区二区三区四区</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>