crypto Module
Note:
The crypto module cannot be directly imported using the import crypto command. Otherwise, an error message indicating that the crypto package cannot be found is displayed during compilation (error: can not find package'crypt'). It is recommended that you use the crypto module in the form of an imported crypto subpackage.
crypto Function Description
The crypto module provides security encryption capabilities, including generating secure random numbers, generating message digests, encrypting and signing data, and creating and parsing certificates.
In actual applications, the crypto module is used to encrypt user passwords, protect sensitive data, and generate digital signatures.
Package List of the crypto Module
The crypto module provides the following packages:
Name | Description |
---|---|
crypto | The crypto package provides the secure random number function. |
digest | The digest package provides common message digest algorithms, including MD5, SHA1, SHA224, SHA256, SHA384, SHA512, HMAC, and SM3. |
keys | The keys package provides asymmetric encryption and signature algorithms, including RSA and SM2 asymmetric encryption algorithms and the ECDSA signature algorithm. |
x509 | The x509 package provides digital certificate processing functions, including parsing and serializing x509 certificates, verifying certificates, creating self-signed certificates, and creating and verifying certificate chains. |