Current location - Quotes Website - Signature design - Java encryption and digital signature 1 message digest
Java encryption and digital signature 1 message digest
This paper mainly discusses encryption and digital signature in cryptography and how to use them in java. Partners who are interested in cryptography recommend Bruce Schneier's book Applied Cryptography, which has greatly improved the security in the release version of jdk and provided direct support for RSA algorithm. Now let's start with an example of solving the problem (this article is just a brief introduction).

A concept commonly used in cryptography

) message summary

This is a technology combined with message authentication code to ensure the integrity of the message. It mainly adopts one-way hash function algorithm, which can be used to check the integrity of messages and save them directly in text form through hash passwords. At present, MD MD SHA jdk provides support for all the above contents. It is very simple to summarize messages in java, and java security MessageDigest provides a simple operation method.

Java code

/* * * MessageDigestExample Java * Copyright */import Java security message digest; /* * * Single message digest algorithm can be used to hide and save plaintext messages (such as passwords) */public class messagedigest {public static void main (string [] args) throwsexception {if (argslength! = ){ System err println (usage: Java message digest sample text); System exit (); } byte[]platext = args[]getBytes(UTF); //Use getInstance (algorithm) to get the message digest. Here, SHA's bit algorithm Message Digest = Message Digest GetInstance (Sha) is used; system out println(+message digest get provider()getInfo()); //Start using the algorithm messageDigest update (plaintext); System output println (abstract:); //Output algorithm operation result System Out Println (New String (Message Digest Digest () UTF)); }}

Lishi Xinzhi/Article/program/Java/gj/20 13 1 1/27287