Using Java commonly used encryption, decryption, digital signature, etc.

zhaozj2021-02-16  49

Common API

java.security.KeyPairGenerator key generator class public static KeyPairGenerator getInstance (String algorithm) throws NoSuchAlgorithmException a specified algorithm returns KeyPairGenerator object Parameters: algorithm, such as algorithm name:. "DSA", "RSA"

Public void Initialize (int keysize)

Initialize the KeypairGenerator object with the specified length, if no initialization system is set by default 1024 length

Parameters: Keysize algorithm is long. The range must be between 512 and 1024, and must be a multiple of 64

Public Void Initialize (int key, secondom random) with the specified length initialization and random generator object parameters: Keysize algorithm is long. The range must be between 512 and 1024, and must be a multiple of 64 Random. Source (for Initialize (int Keysize) used by default

Public Abstract Keypair GenerateKeyPair () Generates a new key pair

Java.Security.KeyPAIR Key Public PrivateKey getPrivate () Returns private key

Public publickey getpublic () Returns public key

Java.security.signature GetInstance (String Algorithm) THROWS NOSUCHALGORITHMEXCEPTION Returns a specified algorithm Signature object parameter algorithm such as "DSA"

Public Final Void INITSIGN (PrivateKey PrivateKey) THROWS INVALIDKEYEXCEPTION uses the specified private key initialization parameter: private key when the privateKey is signed

public final void update (byte data) throws SignatureExceptionpublic final void update (byte [] data) throws SignatureExceptionpublic final void update (byte [] data, int off, int len) throws SignatureException signature information to be added

Public final byte [] sign () THROWS SIGNATureException Returns the array of signatures, provided INITSIGN and UPDATE

Public final void initverify (publickey publickey) THROWS INVALIDKEYEXCEPTION Published parameters with the specified public key: public key used in publickey verification

Public final boolean verify (Byte [] signature) THROWS SIGNATUREXCEPTION Verify that the signature is valid, the premise is already initverify initialization parameters: Signature Signature array

转载请注明原文地址:https://www.9cbs.com/read-24957.html

New Post(0)