Java secure communications, digital certificates and application practices

Source: Internet
Author: User

Summary :

In this article, I use a detailed language and a large number of pictures and complete program source to show you how in Java in the implementation of message digest, message authentication code to achieve secure communication, and the use of Java tools to generate digital certificates, and use the program to sign digital certificates, As well as the process of signing the applet with the signed mathematical certificate to break the access rights of the applet, the detailed code of all examples is given.

In this article you can learn the following knowledge:

How to communicate securely between programs

What is and how to generate a message digest

What is and how to generate a message authentication code

How to build and maintain a digital certificate library using Java tools

How to authenticate a signature to a digital certificate by using a program

How to use digital certificate to give applet signature break through Applet's access rights

Key Words :

Message digest, message authentication code, fingerprint, encryption, security, Java, digital signature, applet, digital certificate

First, basic knowledge

In the process of computer secure communication, message digest and message authentication code are used to ensure that the transmitted data has not been modified by the third party.

The message digest is the result of calculating the original data according to a certain algorithm, it mainly detects whether the original data has been modified. Message digest is different from encryption, encryption is a transformation of the original data, you can get the original data from the transformed data, and the message digest is to get some information from the raw data, it is much less than the original data, so the message digest can be considered as the fingerprint of the original data.

Example: The following procedure calculates a message digest for a string

package com.messagedigest;
import java.security.*;
public class DigestPass {
 public static void main(String[] args) throws Exception{
  String str="Hello,I sent to you 80 yuan.";
  MessageDigest md = MessageDigest.getInstance("MD5");//常用的有MD5,SHA算法等
  md.update(str.getBytes("UTF-8"));//传入原始字串
  byte[] re = md.digest();//计算消息摘要放入byte数组中
  //下面把消息摘要转换为字符串
  String result = "";
  for(int i=0;i<re.length;i++){
   result += Integer.toHexString((0x000000ff&re[i])|0xffffff00).substring(6);
  }
  System.out.println(result);
 }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.