当前位置: 首页>>代码示例>>Java>>正文


Java SunJCE类代码示例

本文整理汇总了Java中com.sun.crypto.provider.SunJCE的典型用法代码示例。如果您正苦于以下问题:Java SunJCE类的具体用法?Java SunJCE怎么用?Java SunJCE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SunJCE类属于com.sun.crypto.provider包,在下文中一共展示了SunJCE类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.sun.crypto.provider.SunJCE; //导入依赖的package包/类
public static void main(String argv[]) throws Exception {
        String mode = "USE_SKIP_DH_PARAMS";

        // Add JCE to the list of providers
        SunJCE jce = new SunJCE();
        Security.addProvider(jce);

        DHKeyAgreement2 keyAgree = new DHKeyAgreement2();

        if (argv.length > 1) {
            keyAgree.usage();
            throw new Exception("Wrong number of command options");
        } else if (argv.length == 1) {
            if (!(argv[0].equals("-gen"))) {
                keyAgree.usage();
                throw new Exception("Unrecognized flag: " + argv[0]);
            }
            mode = "GENERATE_DH_PARAMS";
        }

        keyAgree.run(mode);
        System.out.println("Test Passed");
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:24,代码来源:DHKeyAgreement2.java

示例2: DESPlus

import com.sun.crypto.provider.SunJCE; //导入依赖的package包/类
public DESPlus(String strKey) throws Exception {
	Security.addProvider(new SunJCE());
	Key key = getKey(strKey.getBytes());

	this.encryptCipher = Cipher.getInstance("DES");
	this.encryptCipher.init(1, key);

	this.decryptCipher = Cipher.getInstance("DES");
	this.decryptCipher.init(2, key);
}
 
开发者ID:rememberber,项目名称:WeSync,代码行数:11,代码来源:DESPlus.java

示例3: main

import com.sun.crypto.provider.SunJCE; //导入依赖的package包/类
public static void main(String argv[]) throws Exception {
        // Add JCE to the list of providers
        SunJCE jce = new SunJCE();
        Security.addProvider(jce);

        DHKeyAgreement3 keyAgree = new DHKeyAgreement3();
        keyAgree.run();
        System.out.println("Test Passed");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:DHKeyAgreement3.java

示例4: main

import com.sun.crypto.provider.SunJCE; //导入依赖的package包/类
public static void main(String argv[]) throws Exception {
        // Add JCE to the list of providers
        SunJCE jce = new SunJCE();
        Security.addProvider(jce);

        DHKeyFactory test = new DHKeyFactory();
        test.run();
        System.out.println("Test Passed");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:DHKeyFactory.java

示例5: main

import com.sun.crypto.provider.SunJCE; //导入依赖的package包/类
public static void main(String argv[]) throws Exception {
    // Add JCE to the list of providers
    SunJCE jce = new SunJCE();
    Security.addProvider(jce);

    TestLeadingZeroes keyAgree = new TestLeadingZeroes();
    keyAgree.run();
    System.out.println("Test Passed");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TestLeadingZeroes.java

示例6: DESUtil

import com.sun.crypto.provider.SunJCE; //导入依赖的package包/类
private DESUtil(String key) throws NoSuchPaddingException,NoSuchAlgorithmException,InvalidKeyException{

		Security.addProvider(new SunJCE());
		Key _key = getKey(key.getBytes());
		
		encryptCipher = Cipher.getInstance("DES");
		encryptCipher.init(Cipher.ENCRYPT_MODE, _key);//加密
		
		decryptCipher = Cipher.getInstance("DES");
		decryptCipher.init(Cipher.DECRYPT_MODE, _key);//解密
	}
 
开发者ID:anylineorg,项目名称:anyline,代码行数:12,代码来源:DESUtil.java

示例7: decrypt

import com.sun.crypto.provider.SunJCE; //导入依赖的package包/类
public static  String decrypt(String args, String key) {
	try {
		Des3Util d3u = new Des3Util();

		Security.addProvider(new SunJCE());

		return d3u.decryptFromBase64(key, args, "UTF-8");
	} catch (Exception e) {
		e.printStackTrace();

	}
	return null;
}
 
开发者ID:uustory,项目名称:U8Server,代码行数:14,代码来源:Des3Util.java

示例8: encrypt

import com.sun.crypto.provider.SunJCE; //导入依赖的package包/类
public static  String encrypt(String body, String key) {
	try {
		Des3Util d3u = new Des3Util();

		Security.addProvider(new SunJCE());

		return d3u.encryptToBase64(key, body, "UTF-8");
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:uustory,项目名称:U8Server,代码行数:13,代码来源:Des3Util.java

示例9: loadDefaultEncryptionModule

import com.sun.crypto.provider.SunJCE; //导入依赖的package包/类
/** Load the default encryption module.
 *
 * <p>By default this is the SunJCE module.
 */
public static void loadDefaultEncryptionModule() {
	// Be sure that the cryptographical algorithms are loaded
	final Provider[] providers = Security.getProviders();
	boolean found = false;
	for (final Provider provider : providers) {
		if (provider instanceof SunJCE) {
			found = true;
			break;
		}
	}
	if (!found) {
		Security.addProvider(new SunJCE());
	}
}
 
开发者ID:gallandarakhneorg,项目名称:afc,代码行数:19,代码来源:Encryption.java

示例10: main

import com.sun.crypto.provider.SunJCE; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        Provider prov = new com.sun.crypto.provider.SunJCE();
        Security.addProvider(prov);

        SecureRandom sr = new SecureRandom();

        // Create new DES key.
        KeyGenerator kg = KeyGenerator.getInstance("DES");
        kg.init(sr);
        Key key = kg.generateKey();

        // Generate an IV.
        byte[] iv_bytes = new byte[8];
        sr.nextBytes(iv_bytes);
        IvParameterSpec iv = new IvParameterSpec(iv_bytes);

        // Create the consumer
        Cipher decrypter = Cipher.getInstance("DES/CFB8/NoPadding");
        decrypter.init(Cipher.DECRYPT_MODE, key, iv);
        PipedInputStream consumer = new PipedInputStream();
        InputStream in = new CipherInputStream(consumer, decrypter);

        // Create the producer
        Cipher encrypter = Cipher.getInstance("DES/CFB8/NoPadding");
        encrypter.init(Cipher.ENCRYPT_MODE, key, iv);
        PipedOutputStream producer = new PipedOutputStream();
        OutputStream out = new CipherOutputStream(producer, encrypter);

        producer.connect(consumer); // connect pipe

        byte[] plaintext = "abcdef".getBytes();
        for (int i = 0; i < plaintext.length; i++) {
            out.write(plaintext[i]);
            out.flush();
            int b = in.read();
            String original = new String(plaintext, i, 1);
            String result = new String(new byte[] { (byte)b });
            System.out.println("  " + original + " -> " + result);
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:42,代码来源:FlushBug.java


注:本文中的com.sun.crypto.provider.SunJCE类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。