Java code signature and authentication

Source: Internet
Author: User

After reading the content of this chapter, I feel that some of them are very familiar, because Android signature authentication is based on the Java mechanism. Signature and authentication process

The encryption and decryption processes and principles of public and private keys need to be further studied. An example of signature and authentication is as follows:

1. Write doer Inherited Characters for classes like friend and stranger
2. Pack friend and stranger into jar packages respectively.

Jar CVF friend. Jar COM/artima/security/friend/*. classjar CVF stranger. Jar COM/artima/security/stranger/*. Class

3. generate two key pairs

Keytool-genkey-alias friend-keypass friend4life-validity 10000-keystore ijvmkeyskeytool-genkey-alias stranger-keypass stranger4life-validity 10000-keystore ijvmkeys

The two passwords must be consistent. Because you need to access the keystore when adding the key for the second time, you need to set the password for the first time.
4. Use jarsigner to sign

Jarsigner-keystore ijvmkeys-storepass ijvm2ed-keypass friend4life friend. Jar friendjarsigner-keystore ijvmkeys-storepass ijvm2ed-keypass stranger4life stranger. Jar stranger

After the signed JAR package is modified, running the jar package reports a java. Lang. securityexception exception.

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.