- 浏览: 2552309 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
bouncycastle(1) Use bouncy castle provider runtime
JCE is the short for The Java Cryptography Extension.
From this class, we can see the provider list of my JDK.
package com.sillycat.easycastle.tools;
import java.security.Provider;
import java.security.Security;
import java.util.Iterator;
import java.util.Set;
publicclass ProviderInformation {
publicstaticvoid main(String[] args) {
Provider[] providers = Security.getProviders();
for (int i = 0; i < providers.length; i++) {
Provider provider = providers[i];
System.out.println("Provider name: " + provider.getName());
System.out.println("Provider information: " + provider.getInfo());
System.out.println("Provider version: " + provider.getVersion());
Set<?> entries = provider.entrySet();
Iterator<?> iterator = entries.iterator();
while (iterator.hasNext()) {
System.out.println("Property entry: " + iterator.next());
}
}
}
}
And I use a test class to verify DES with bouncy castle:
package com.sillycat.easycastle.runner;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
public class DESEncryptAndDecrypt {
private static final String JCE_PROVIDER_BC = "BC";
public static void main(String[] args) {
//Security.addProvider(new com.sun.crypto.provider.SunJCE());
Security.addProvider(new BouncyCastleProvider());
try {
// "BC" is the name of the BouncyCastle provider
KeyGenerator kg = KeyGenerator.getInstance("DES",JCE_PROVIDER_BC);
Key key = kg.generateKey();
Cipher cipher = Cipher.getInstance("DES",JCE_PROVIDER_BC);
byte[] data = "Hello World!".getBytes();
System.out.println("Original data : " + new String(data));
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] result = cipher.doFinal(data);
System.out.println("Encrypted data: " + new String(result));
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] original = cipher.doFinal(result);
System.out.println("Decrypted data: " + new String(original));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (NoSuchProviderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I import the package in pom.xml like this:
<dependency>
<groupId>bouncycastle</groupId>
<artifactId> bcprov-jdk16</artifactId>
<version> 140</version>
</dependency>
references:
http://www.bouncycastle.org
http://www.bouncycastle.org/specifications.html#install
http://hi.baidu.com/bluewhale84/blog/item/f3bb20a1f538a9884710648c.html
http://security.group.iteye.com/group/wiki/2280-Non-symmetric-encryption-Digital-Signature
http://snowolf.iteye.com/blog/379860
http://sillycat.iteye.com/blog/563515
JCE is the short for The Java Cryptography Extension.
From this class, we can see the provider list of my JDK.
package com.sillycat.easycastle.tools;
import java.security.Provider;
import java.security.Security;
import java.util.Iterator;
import java.util.Set;
publicclass ProviderInformation {
publicstaticvoid main(String[] args) {
Provider[] providers = Security.getProviders();
for (int i = 0; i < providers.length; i++) {
Provider provider = providers[i];
System.out.println("Provider name: " + provider.getName());
System.out.println("Provider information: " + provider.getInfo());
System.out.println("Provider version: " + provider.getVersion());
Set<?> entries = provider.entrySet();
Iterator<?> iterator = entries.iterator();
while (iterator.hasNext()) {
System.out.println("Property entry: " + iterator.next());
}
}
}
}
And I use a test class to verify DES with bouncy castle:
package com.sillycat.easycastle.runner;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
public class DESEncryptAndDecrypt {
private static final String JCE_PROVIDER_BC = "BC";
public static void main(String[] args) {
//Security.addProvider(new com.sun.crypto.provider.SunJCE());
Security.addProvider(new BouncyCastleProvider());
try {
// "BC" is the name of the BouncyCastle provider
KeyGenerator kg = KeyGenerator.getInstance("DES",JCE_PROVIDER_BC);
Key key = kg.generateKey();
Cipher cipher = Cipher.getInstance("DES",JCE_PROVIDER_BC);
byte[] data = "Hello World!".getBytes();
System.out.println("Original data : " + new String(data));
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] result = cipher.doFinal(data);
System.out.println("Encrypted data: " + new String(result));
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] original = cipher.doFinal(result);
System.out.println("Decrypted data: " + new String(original));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (NoSuchProviderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I import the package in pom.xml like this:
<dependency>
<groupId>bouncycastle</groupId>
<artifactId> bcprov-jdk16</artifactId>
<version> 140</version>
</dependency>
references:
http://www.bouncycastle.org
http://www.bouncycastle.org/specifications.html#install
http://hi.baidu.com/bluewhale84/blog/item/f3bb20a1f538a9884710648c.html
http://security.group.iteye.com/group/wiki/2280-Non-symmetric-encryption-Digital-Signature
http://snowolf.iteye.com/blog/379860
http://sillycat.iteye.com/blog/563515
发表评论
-
Update Site will come soon
2021-06-02 04:10 1679I am still keep notes my tech n ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 431Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 436Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 374Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 455VPN Server 2020(2)Docker on Cen ... -
Nginx Deal with OPTIONS in HTTP Protocol
2020-02-15 01:33 356Nginx Deal with OPTIONS in HTTP ... -
PDF to HTML 2020(1)pdftohtml Linux tool or PDFBox
2020-01-29 07:37 405PDF to HTML 2020(1)pdftohtml Li ... -
Elasticsearch Cluster 2019(2)Kibana Issue or Upgrade
2020-01-12 03:25 720Elasticsearch Cluster 2019(2)Ki ... -
Spark Streaming 2020(1)Investigation
2020-01-08 07:19 295Spark Streaming 2020(1)Investig ... -
Hadoop Docker 2019 Version 3.2.1
2019-12-10 07:39 295Hadoop Docker 2019 Version 3.2. ... -
MongoDB 2019(3)Security and Auth
2019-11-16 06:48 241MongoDB 2019(3)Security and Aut ... -
MongoDB 2019(1)Install 4.2.1 Single and Cluster
2019-11-11 05:07 294MongoDB 2019(1) Follow this ht ... -
Monitor Tool 2019(1)Monit Installation and Usage
2019-10-17 08:22 325Monitor Tool 2019(1)Monit Insta ... -
Ansible 2019(1)Introduction and Installation on Ubuntu and CentOS
2019-10-12 06:15 312Ansible 2019(1)Introduction and ... -
Timezone and Time on All Servers and Docker Containers
2019-10-10 11:18 332Timezone and Time on All Server ... -
Kafka Cluster 2019(6) 3 Nodes Cluster on CentOS7
2019-10-05 23:28 283Kafka Cluster 2019(6) 3 Nodes C ... -
K8S Helm(1)Understand YAML and Kubectl Pod and Deployment
2019-10-01 01:21 326K8S Helm(1)Understand YAML and ... -
Rancher and k8s 2019(5)Private Registry
2019-09-27 03:25 362Rancher and k8s 2019(5)Private ... -
Jenkins 2019 Cluster(1)Version 2.194
2019-09-12 02:53 444Jenkins 2019 Cluster(1)Version ... -
Redis Cluster 2019(3)Redis Cluster on CentOS
2019-08-17 04:07 373Redis Cluster 2019(3)Redis Clus ...
相关推荐
1. **bcprov-jdk15on-1.62.jar**:这是BouncyCastle的主要加密提供者包,提供了广泛的加密算法实现,如RSA、AES、DES、SHA等。它支持Java 1.5及更高版本,因此名称中的"jdk15on"表示这个版本适用于Java 1.5及以上。...
**Bouncy Castle简介** Bouncy Castle是一个开源的Java加密库,提供了广泛的加密算法、协议实现以及相关的工具。这个jar包是专门为Java开发者设计的,它弥补了Java标准加密API(如JCE)在某些功能上的不足,使得...
Bouncy Castle API 提供了两种主要的接口:轻量级 API(Lightweight API)和提供更全面功能的提供商 API(Provider API)。轻量级 API 更加简洁,适用于那些对性能有高要求的场景,而提供商 API 则更接近 Java 安全...
** org.bouncycastle 加密算法包详解 ** `org.bouncycastle` 是一个开源的 Java 库,专门用于实现各种加密算法和相关的安全服务。它提供了广泛的加密功能,包括对称和非对称加密、数字签名、哈希函数、证书管理、...
解决org/bouncycastle/jce/provider/bouncycastlepr错误专用。
《BouncyCastle.Crypto.dll:理解.NET平台的加密利器》 在网络安全日益重要的今天,加密技术扮演了至关重要的角色。BouncyCastle库是Java和.NET平台上广泛使用的加密库之一,而"BouncyCastle.Crypto.dll"正是.NET...
**Bouncy Castle 加密开源组件API Java Release 1.46** 是一个广泛使用的加密库,尤其在Java开发中占据重要地位。Bouncy Castle 提供了丰富的加密算法、密钥生成器、证书处理以及PKI(Public Key Infrastructure,...
1. **加密算法支持**:BouncyCastle.Crypto.dll 提供了多种加密算法的实现,包括对称加密(如AES、Blowfish、DES)、非对称加密(如RSA、DSA、ECDSA)、哈希函数(如SHA-1、SHA-256、MD5)和消息认证码(MAC)。...
《BouncyCastle.Crypto:C#中的加密库详解》 在信息安全领域,加密技术是保障数据安全的关键。本文将深入探讨BouncyCastle.Crypto.dll,一个广泛使用的C#加密库,版本1.8.1。BouncyCastle项目,被誉为"The Legion ...
BouncyCastle.dll 是一个在C#环境中广泛使用的开源加密库,它为.NET Framework提供了一整套强大的加密功能。这个库是基于Bouncy Castle项目,这是一个跨平台的Java和.NET加密库,提供了各种加密算法、密码协议和PKI...
1. **多语言支持**:BouncyCastle 提供了跨平台的实现,包括.NET和Java版本,使得开发跨平台应用时能保持一致性。 2. **广泛的密码学算法**:BouncyCastle 支持众多加密算法,如AES、DES、3DES、Blowfish、RSA、DSA...
BouncyCastle.Crypto.dll是.NET版本的核心组件,包含了大量加密算法的实现,如对称加密(如AES、DES、3DES)、非对称加密(RSA、DSA、ECC)、哈希算法(MD5、SHA-1、SHA-256等)以及消息认证码(MAC)等。...
"bcprov"代表BouncyCastle Provider,"jdk16"表示这个版本是针对Java 1.6编译的。版本号1.46意味着这是一个较旧但仍然广泛使用的版本。这个库包含了各种加密算法的实现,如RSA、AES、DES等,还支持PKCS#7、CMS、X....
《BouncyCastle.Crypto.dll 1.8.2:深入解析加密库的奥秘》 在信息技术领域,安全是至关重要的。特别是在网络通信、数据存储和传输等方面,强大的加密技术是保障信息安全的基础。BouncyCastle.Crypto.dll是这样一个...
《BouncyCastle1.59帮助文档:深入理解与CHM制作详解》 BouncyCastle,作为Java和.NET平台上广泛使用的开源加密库,为开发者提供了丰富的加密算法、密码学标准接口以及证书处理功能。这份“BouncyCastle1.59帮助...
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.6.
1. **导入BouncyCastle库**:首先需要在C#项目中引用BouncyCastle库。这可以通过NuGet包管理器完成,安装`BCryptNet`和`BouncyCastle.Crypto`这两个包。 2. **生成或加载RSA密钥对**:签名需要私钥,而验签则需要...