java pkcs7_使用PKCS#7进行加密解密

本文示例展示了如何在Java中使用PKCS#7进行加密解密,引用了 Beginning Cryptography With Java 一书中的代码。主要内容包括如何生成签名,以及关于加密数据的存储、恢复原始数据、密钥传递和数据格式等问题的探讨。
摘要由CSDN通过智能技术生成

我想使用PKCS#7加密解密数据 . 在探索时我发现了一本书 Beginning Cryptography With Java

在本书的第9章中有一个示例代码如下

import java.security.KeyStore;

import java.security.PrivateKey;

import java.security.cert.*;

import java.util.Arrays;

import org.bouncycastle.cms.CMSProcessable;

import org.bouncycastle.cms.CMSProcessableByteArray;

import org.bouncycastle.cms.CMSSignedData;

import org.bouncycastle.cms.CMSSignedDataGenerator;

/**

* Example of generating a detached signature.

*/

public class SignedDataExample

extends SignedDataProcessor

{

public static void main(String[] args) throws Exception

{

KeyStore credentials = Utils.createCredentials();

PrivateKey key = (PrivateKey)credentials.getKey(

Utils.END_ENTITY_ALIAS, Utils.KEY_PASSWD);

Certificate[] chain = credentials.g

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Beginning Cryptography with Java While cryptography can still be a controversial topic in the programming community, Java has weathered that storm and provides a rich set of APIs that allow you, the developer, to effectively include cryptography in applications-if you know how. This book teaches you how. Chapters one through five cover the architecture of the JCE and JCA, symmetric and asymmetric key encryption in Java, message authentication codes, and how to create Java implementations with the API provided by the Bouncy Castle ASN.1 packages, all with plenty of examples. Building on that foundation, the second half of the book takes you into higher-level topics, enabling you to create and implement secure Java applications and make use of standard protocols such as CMS, SSL, and S/MIME. What you will learn from this book How to understand and use JCE, JCA, and the JSSE for encryption and authentication The ways in which padding mechanisms work in ciphers and how to spot and fix typical errors An understanding of how authentication mechanisms are implemented in Java and why they are used Methods for describing cryptographic objects with ASN.1 How to create certificate revocation lists and use the Online Certificate Status Protocol (OCSP) Real-world Web solutions using Bouncy Castle APIs Who this book is for This book is for Java developers who want to use cryptography in their applications or to understand how cryptography is being used in Java applications. Knowledge of the Java language is necessary, but you need not be familiar with any of the APIs discussed. Wrox Beginning guides are crafted to make learning programming languages and technologies easier than you think, providing a structured, tutorial format that will guide you through all the techniques involved.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值