java中使用公钥加密私钥解密原理实现license控制

java中使用公钥加密私钥解密原理实现license控制
1.现在很多J2EE应用都采用一个license文件来授权系统的使用,特别是
在系统购买的早期,会提供有限制的license文件对系统进行限制,比如试用版有譬如IP、日期、最大用户数量的限制等。

2.
3.而license控制的方法又有很多,目前比较流行,只要设计的好就很难破
解的方法就是采用一对密匙(私匙加密公匙解密)来生成License文件中的Sinature签名内容,再通过Base64或Hex来进行编码。

比如原BEA 公司现在是Oracle公司的WebLogic就采用的是这种方法来设置License 文件。

4.
5.这里只进行一个比较简单的实现:
6.
7.一共三个类:
8.
9. A.KeyGenerater类生成公钥私钥对
10.
11.B.Signaturer类使用私钥进行签名
12.
13.C.SignProvider类用公钥验证
14.
15.公钥和私钥使用Base64加密Base64这个类很多地方都可以查到。

16.
17.
18.
19.KeyGenerater类:
20.
21.
22.
23.public class KeyGenerater {
24.
25. private byte[] priKey;
26.
27. private byte[] pubKey;
28.
29. public void generater() {
30. try {
31.
32. KeyPairGenerator keygen = KeyPairGenerator .getInstance("RSA"
);
33.
34. SecureRandom secrand = new SecureRandom();
36. secrand.setSeed("www.川江号子.cn".getBytes()); // 初始化随机
产生器
37.
38. keygen.initialize(1024, secrand);
39.
40. KeyPair keys = keygen.genKeyPair();
41.
42. PublicKey pubkey = keys.getPublic();
43.
44. PrivateKey prikey = keys.getPrivate()
45.
46. pubKey = Base64.encodeToByte(pubkey.getEncoded());
47.
48. priKey = Base64.encodeToByte(prikey.getEncoded());
49.
50. System.out.println("pubKey = " + new String(pubKey));
51.
52. System.out.println("priKey = " + new String(priKey));
53.
54. } catch (ng.Exception e) {
55.
56. System.out.println("生成密钥对失败");
57.
58. e.printStackTrace();
59.
60. }
61.
62. }
63.
64. public byte[] getPriKey() {
65.
66. return priKey;
67.
68. }
69.
70. public byte[] getPubKey() {
71.
72. return pubKey;
73.
74. }
75.
76.}
77.
79.Signaturer 类:
80.
81.
82.
83.public class Signaturer {
84.
85. public static byte[] sign(byte[] priKeyText, String plainText)
{
86.
87. try {
88.
89. PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(Base6
4.decode(priKeyText));
90.
91. KeyFactory keyf = KeyFactory.getInstance("RSA");
92.
93. PrivateKey prikey = keyf.generatePrivate(priPKCS8);
94.
95. // 用私钥对信息生成数字签名
96.
97. Signature signet = java.security.Signature.getInstance("MD5
withRSA");
98.
99. signet.initSign(prikey);
100.
101. signet.update(plainText.getBytes());
102.
103. byte[] signed = Base64.encodeToByte(signet.sign()); 104.
105. return signed;
106.
107. } catch (ng.Exception e) {
108.
109. System.out.println("签名失败");
110.
111. e.printStackTrace();
112.
113. }
114.
115. return null;
116.
117. }
118.
119.}
120.
121.
122. SignProvider 类:
123.
124.public class SignProvider {
125.
126. private SignProvider() {
127.
128. }
129.
130. public static boolean verify(byte[] pubKeyText, String pl ainText,
131.
132. byte[] signText) {
133.
134. try {
135.
136. // 解密由base64编码的公钥,并构造X509EncodedKeySpec对象
137.
138. X509EncodedKeySpec bobPubKeySpec = new X509EncodedKeySp ec(Base64.decode(pubKeyText));
139.
140. // RSA对称加密算法
141.
142. KeyFactory keyFactory = KeyFactory.getInstance("RSA");
143.
144. // 取公钥匙对象
145.
146. PublicKey pubKey = keyFactory.generatePublic(bobPubKeyS pec);
147.
148. // 解密由base64编码的数字签名
149.
150. byte[] signed = Base64.decode(signText);
151.
152. Signature signatureChecker = Signature.getInstance("MD5 withRSA");
153.
154. signatureChecker.initVerify(pubKey);
155.
156. signatureChecker.update(plainText.getBytes());
157.
158. // 验证签名是否正常
159.
160. if (signatureChecker.verify(signed)) 161.
162. return true;
163.
164. else
165.
166. return false;
167.
168. } catch (Throwable e) {
169.
170. System.out.println("校验签名失败"); 171.
172. e.printStackTrace();
173.
174. return false;
175.
176. }
177.
178. }
179.
180.}。

合集下载

java rsa加密解密实例

java rsa加密解密实例

java rsa加密解密实例这是一个使用Java进行RSA加密和解密的简单示例。

这个示例使用了Java的内置加密库,并且只适用于小数据块的加密和解密。

对于大数据块,你可能需要使用一种称为"混合加密"的技术,将数据分成小块并分别加密。

首先,我们需要导入一些必要的库:```javaimport ;import ;import ;```然后,我们可以生成RSA密钥对:```javaKeyPairGenerator keyGen = ("RSA");(2048);KeyPair pair = ();PrivateKey privateKey = ();PublicKey publicKey = ();```接下来,我们可以使用公钥进行加密,然后使用私钥进行解密。

首先,我们创建一个Cipher对象用于加密:```javaCipher encryptCipher = ("RSA");(_MODE, publicKey);byte[] cipherText = ("Hello, World!".getBytes());String cipherTextBase64 = ().encodeToString(cipherText);```然后,我们创建一个Cipher对象用于解密:```javaCipher decryptCipher = ("RSA");(_MODE, privateKey);byte[] plainText = (().decode(cipherTextBase64));String plainTextStr = new String(plainText);```现在,`plainTextStr`就是解密后的原始文本。

注意,这个例子中的数据是硬编码的,并且只包含英文字符。

如果你的数据包含其他字符(例如中文字符),或者你需要处理的数据量很大,你可能需要使用不同的方法。

Java加密与解密方法详解

Java加密与解密方法详解

Java加密与解密方法详解1. 引言在当今数字化时代,保护数据的安全性成为了一项重要的任务。

无论是在个人使用还是企业应用中,数据的加密和解密都是必不可少的环节。

而Java作为一门广泛应用于软件开发的编程语言,其提供了丰富的加密和解密方法,本文将对Java中的加密与解密方法进行详细的介绍和分析。

2. 对称加密算法对称加密算法是指加密和解密使用相同的密钥的算法。

Java中常用的对称加密算法有DES、AES等。

其中,DES是一种较早期的对称加密算法,它使用56位的密钥对数据进行加密和解密。

而AES是一种更加安全和高效的对称加密算法,它使用128位、192位或256位的密钥对数据进行加密和解密。

在Java中,使用对称加密算法进行加密和解密的步骤如下:(1)生成密钥:通过密钥生成器(KeyGenerator)生成一个密钥(Key)。

(2)初始化加密/解密器:通过Cipher类的getInstance方法获取加密/解密器,并设置加密/解密模式和密钥。

(3)加密/解密数据:调用加密/解密器的方法对数据进行加密/解密操作。

3. 非对称加密算法非对称加密算法是指加密和解密使用不同的密钥的算法。

Java中常用的非对称加密算法有RSA、DSA等。

其中,RSA是一种基于大数因子分解的非对称加密算法,它使用公钥和私钥对数据进行加密和解密。

在Java中,使用非对称加密算法进行加密和解密的步骤如下:(1)生成密钥对:通过密钥对生成器(KeyPairGenerator)生成一个密钥对(KeyPair)。

(2)获取公钥和私钥:通过密钥对获取公钥和私钥。

(3)初始化加密/解密器:通过Cipher类的getInstance方法获取加密/解密器,并设置加密/解密模式和密钥。

(4)加密/解密数据:调用加密/解密器的方法对数据进行加密/解密操作。

4. 哈希算法哈希算法是一种将任意长度的数据映射为固定长度的数据的算法。

Java中常用的哈希算法有MD5、SHA-1、SHA-256等。

java 密码加密解密方法

java 密码加密解密方法

java 密码加密解密方法在Java中,密码的加密和解密可以通过多种方式实现。

其中,常用的方法包括使用MessageDigest类进行加密,以及使用对称加密和非对称加密算法进行加密和解密。

一种常见的密码加密方法是使用MessageDigest类进行加密。

这可以通过以下步骤实现:首先,将密码转换为字节数组。

然后,使用MessageDigest类的getInstance方法获取特定的加密算法实例,例如SHA-256或MD5。

接下来,使用update方法将密码的字节数组传递给MessageDigest实例。

最后,使用digest方法获得加密后的字节数组,并将其转换为十六进制字符串或其他格式存储在数据库或其他地方。

另一种常见的方法是使用对称加密算法,例如AES或DES。

这些算法使用相同的密钥进行加密和解密。

在Java中,可以使用javax.crypto包中的类来实现对称加密。

通常,需要生成一个密钥并将其存储在安全的地方,然后使用该密钥对密码进行加密和解密。

此外,还可以使用非对称加密算法,例如RSA。

这种方法使用公钥对数据进行加密,然后使用私钥进行解密。

在Java中,可以使用java.security包中的类来实现非对称加密。

无论使用哪种方法,都需要注意密码安全的问题。

例如,密钥的安全存储和管理,以及密码传输过程中的安全性。

另外,还需要考虑密码的哈希加盐等技术来增加密码的安全性。

总之,在Java中实现密码的加密和解密有多种方法,开发人员可以根据实际需求和安全要求选择合适的加密算法和实现方式。

希望这些信息能够帮助你更好地理解Java中密码加密解密的方法。

License管理,流程和页面设计

License管理,流程和页面设计

License(产品许可文件)程序逻辑图License发行时填的信息客户的国家地区,所在的行业客户联系人,客户电话,服务代表联系人,服务代表电话;然后重新注册的理由可以通过下拉框进行选择,如果您重新注册的理由不属于列出项,可以在备注中进行补充,最后输入产品序列号、CDKEY、验证码,点击“提交”。

见红色标记。

●License管理首先我们需要确立我们实现的管理目标1、license资源使用的统计、管理和分析2、CAD应用软件使用的统计和分析3、用户使用情况的统计与分析分配license给用户对用户进行分组控制将使用软件的所有用户分成若干组,对应于实际工作中的各个工作/项目组,每组具有不同的优先级。

每一组拥有的license 种类、数量、运行时间窗口都可以由LSF来定义和管理。

根据用户优先级优化软件license的使用用软件的不同用户/项目组具有不同的优先级。

当软件的license数量足够多时,用户都可以正常使用。

当软件license 不足时,高优先级的用户作业将强行抢占低优先级的作业,保证紧要作业的及时完成。

License到期监控及预警许可证到期预警信息窗口能够非常直观的显示各个功能模块的到期预警,以便用户续买License而不妨碍正常工作需求。

此窗口显示信息包括:功能模块的到期时间、功能模块的供应商和软件所在的服务器信息。

许可证服务器预警界面默认显示到当前为止1个月内将到期的所有功能模块内容,每天晚上系统自动的将快到期的功能模块打包作为附件发送到指定的用户邮箱。

同时,用户可以自定义到期时间进行查询更短或更长时间到期的功能模块信息,查询的结果支持导出到Excel和TXT文件中。

License对应实时用户信息许可证管理监控系统(Reporter License的统计分析)许可证管理监控系统(License Reporter简称Reporter)统计本地或者全局的许可证服务器(License Server)详细和准确的使用信息,这些服务器可以分布于任意位置,不同的时区。

使用truelicense实现用于JAVA工程license机制(包括license生成和验证)

使用truelicense实现用于JAVA工程license机制(包括license生成和验证)

使⽤truelicense实现⽤于JAVA⼯程license机制(包括license⽣成和验证)开发的软件产品在交付使⽤的时候,往往会授权⼀段时间的试⽤期,这个时候license就派上⽤场了。

不同于在代码中直接加上时间约束,需要重新授权的时候使⽤license可以避免修改源码,改动部署,授权⽅直接⽣成⼀个新的license发送给使⽤⽅替换掉原来的license⽂件即可。

下⾯将讲述使⽤truelicense来实现license的⽣成和使⽤。

Truelicense是⼀个开源的证书管理引擎,详细介绍见https:/// [此地址已不可⽤(苏醒若蘅注)]⼀、⾸先介绍下license授权机制的原理:1、⽣成密钥对,⽅法有很多。

2、授权者保留私钥,使⽤私钥对包含授权信息(如使⽤截⽌⽇期,MAC地址等)的license进⾏数字签名。

3、公钥给使⽤者(放在验证的代码中使⽤),⽤于验证license是否符合使⽤条件。

接下来是本例制作license的具体步骤:⼆、第⼀步:使⽤keytool⽣成密钥对以下命令在dos命令⾏执⾏,注意当前执⾏⽬录,最后⽣成的密钥对即在该⽬录下:1、⾸先要⽤KeyTool⼯具来⽣成私匙库:(-alias别名 –validity 3650表⽰10年有效)keytool -genkey -alias privatekey -keystoreprivateKeys.store -validity 36502、然后把私匙库内的公匙导出到⼀个⽂件当中:keytool -export -alias privatekey -file certfile.cer -keystore privateKeys.store3、然后再把这个证书⽂件导⼊到公匙库:keytool -import -alias publiccert -file certfile.cer -keystore publicCerts.store最后⽣成⽂件privateKeys.store、publicCerts.store拷贝出来备⽤。

java加密与解密代码

java加密与解密代码

java加密与解密代码当涉及到加密和解密的Java代码时,可以使用Java Cryptography Architecture (JCA) 提供的类和方法来执行这些操作。

以下是一个简单的示例,演示了如何使用Java进行加密和解密:import javax.crypto.Cipher;import javax.crypto.spec.SecretKeySpec;import java.util.Base64;public class EncryptionExample {public static void main(String[] args) {try {String originalString = "Hello, world! This is a message to encrypt.";// 选择加密算法和密钥String encryptionAlgorithm = "AES";String encryptionKey = "thisIsASecretKey"; // 密钥长度根据算法要求,此处是AES的密钥长度// 加密String encryptedString = encrypt(originalString, encryptionKey, encryptionAlgorithm);System.out.println("Encrypted String: " + encryptedString);// 解密String decryptedString = decrypt(encryptedString, encryptionKey, encryptionAlgorithm);System.out.println("Decrypted String: " +decryptedString);} catch (Exception e) {e.printStackTrace();}}public static String encrypt(String input, String key, String algorithm) throws Exception {SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), algorithm);Cipher cipher = Cipher.getInstance(algorithm);cipher.init(Cipher.ENCRYPT_MODE, secretKey);byte[] encryptedBytes = cipher.doFinal(input.getBytes());returnBase64.getEncoder().encodeToString(encryptedBytes);}public static String decrypt(String input, String key, String algorithm) throws Exception {SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), algorithm);Cipher cipher = Cipher.getInstance(algorithm);cipher.init(Cipher.DECRYPT_MODE, secretKey);byte[] decryptedBytes = cipher.doFinal(Base64.getDecoder().decode(input));return new String(decryptedBytes);}}请注意以下几点:- 这个示例使用了对称加密算法 AES (Advanced Encryption Standard),并假设密钥长度为符合算法要求的长度。

java后台加密解密方法

java后台加密解密方法一、加密方法1. 加密算法在Java后台中,常用的加密算法有AES、DES、RSA等。

其中,AES算法是一种对称加密算法,具有较高的安全性和可靠性;DES算法是一种对称分组加密算法,虽然安全性稍逊于AES,但在实际应用中仍然具有一定的安全性;RSA算法是一种非对称加密算法,需要使用私钥和公钥对数据进行加密和解密,适用于数字签名和身份认证等场景。

2. 加密工具在Java中,常用的加密工具包括Java Cryptography Extension (JCE)、Apache Commons Codec等。

JCE提供了各种加密算法的实现,方便开发者使用;Apache Commons Codec则提供了一系列的加密和解密方法,如Base64、Hex、Sha1等。

3. 加密过程加密过程包括数据加密和数据传输加密两个环节。

在数据加密环节,需要根据具体的应用场景选择合适的加密算法和密钥,并将明文数据经过加密算法处理成密文数据。

在数据传输过程中,为了保证数据的安全性,需要使用传输加密算法对数据进行加密,确保数据在传输过程中的安全性。

以下是一个使用AES算法进行数据加密的示例代码:```javaimport javax.crypto.Cipher;import javax.crypto.spec.SecretKeySpec;public class AESEncryptor {private static final String SECRET_KEY = "1234567890123456"; // 密钥private static final String ALGORITHM = "AES"; // 加密算法public static String encrypt(String strToEncrypt) {try {Cipher cipher = Cipher.getInstance(ALGORITHM);SecretKeySpec secretKeySpec = new SecretKeySpec(SECRET_KEY.getBytes(), ALGORITHM);cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);byte[] encryptedByte =cipher.doFinal(strToEncrypt.getBytes());returnBase64.getEncoder().encodeToString(encryptedByte);} catch (Exception e) {e.printStackTrace();}return null;}}```在上述代码中,我们使用AES算法对字符串进行加密,并将加密后的结果使用Base64编码进行输出。

Java读取pem格式公钥私钥实现RSA加解密

Java读取pem格式公钥私钥实现RSA加解密代码如下:⽣成.pem,这⾥使⽤2048位长度:openssl genrsa -out private_key.pem 1024将.pem转为.der:openssl pkcs8 -topk8 -inform PEM -outform DER -in private_key.pem -out private_key.der -nocryptopenssl rsa -in private_key.pem -pubout -outform DER -out public_key.der读取public_key.der:import java.nio.file.Files;import java.nio.file.Paths;import java.security.KeyFactory;import java.security.PublicKey;import java.security.spec.X509EncodedKeySpec;public class PublicKeyReader {public static PublicKey get(String filename) throws Exception {byte[] keyBytes = Files.readAllBytes(Paths.get(filename));X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes);KeyFactory kf = KeyFactory.getInstance("RSA");return kf.generatePublic(spec);}}读取private_key.der:import java.io.DataInputStream;import java.io.File;import java.io.FileInputStream;import java.nio.file.Files;import java.nio.file.Paths;import java.security.KeyFactory;import java.security.PrivateKey;import java.security.spec.PKCS8EncodedKeySpec;public class PrivateKeyReader {public static PrivateKey get(String filename) throws Exception {byte[] keyBytes = Files.readAllBytes(Paths.get(filename));PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);KeyFactory kf = KeyFactory.getInstance("RSA");return kf.generatePrivate(spec);}}测试:import sun.misc.BASE64Decoder;import sun.misc.BASE64Encoder;import java.io.IOException;import java.nio.charset.StandardCharsets;import java.security.PrivateKey;import java.security.PublicKey;public class RSAReadKeyTest {public static void main(String[] args) throws Exception {String text = "When and where\n" +"Join us on June 25, 2020 10:00 Pacific Daylight Time. The workshops will be livestreamed to YouTube via Google Cloud Platform in partnership with AI Huddle.\n" +"\n" +"Is this for me?\n" +"This session is especially geared for professional working data scientists. You should be comfortable with Python to build machine or deep learning models. If you’re curious how accelerators can improve your workflow, this is for you "\n" +"Agenda\n" +"Session 1: 10:00-10:30 AM PDT\n" +"Compete in a Kaggle Competition Using TensorFlow GPUs with Chris Deotte \n" +"“Follow along as I make a simple notebook from my team's Gold medal solution to Bengali Handwriting Classification competition.”\n" +"\n" +"Session 2: 10:30-11:00 AM PDT \n" +"Approach (Almost) Any Deep Learning Problem Using PyTorch and TPUs with Abhishek Thakur\n" +"“Allow me to show you how to harness the power of TPUs and Pytorch to quickly train almost any model!”";PublicKey pubKey = PublicKeyReader.get("src/gj/secure/rsa_public_key.der");byte[] bytes = RSAUtil.encryptByPublicKey(pubKey, text.getBytes());String cipherText = toBase64(bytes);System.out.println(cipherText);PrivateKey priKey = PrivateKeyReader.get("src/gj/secure/rsa_private_key.der");byte[] cipherBytes = fromBase64(cipherText);byte[] result = RSAUtil.decryptByPrivateKey(priKey, cipherBytes);System.out.println(new String(result, StandardCharsets.UTF_8));}public static String toBase64(byte[] bytes) {return new BASE64Encoder().encode(bytes);}public static byte[] fromBase64(String b64String) throws IOException {return new BASE64Decoder().decodeBuffer(b64String);}}附RSAUtil.java代码:import javax.crypto.Cipher;import java.io.ByteArrayOutputStream;import java.security.*;/*** @author areful* Date: 2019/2/12*/public class RSAUtil {public static final String ALGORITHM_RSA = "RSA";public static final String ALGORITHM_RSA_PKCS1PADDING = "RSA/ECB/PKCS1PADDING";public static final String SIGNATURE_ALGORITHM = "MD5withRSA";private static final int MAX_ENCRYPT_BLOCK = 117;private static final int MAX_DECRYPT_BLOCK = 128;public static KeyPair genKeyPair() throws Exception {KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(ALGORITHM_RSA);keyPairGen.initialize(1024);return keyPairGen.generateKeyPair();}public static byte[] encryptByPublicKey(PublicKey pubKey, byte[] data) throws Exception {return doFinal(pubKey, Mode.ENCRYPT, data);}public static byte[] decryptByPrivateKey(PrivateKey priKey, byte[] data) throws Exception {return doFinal(priKey, Mode.DECRYPT, data);}public static byte[] encryptByPrivateKey(PrivateKey priKey, byte[] data) throws Exception {return doFinal(priKey, Mode.ENCRYPT, data);}public static byte[] decryptByPublicKey(PublicKey pubKey, byte[] data) throws Exception {return doFinal(pubKey, Mode.DECRYPT, data);}public static byte[] sign(PrivateKey priKey, byte[] data) throws Exception {Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);signature.initSign(priKey);signature.update(data);return signature.sign();}public static boolean verify(PublicKey pubKey, byte[] data, byte[] sign) throws Exception {Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);signature.initVerify(pubKey);signature.update(data);return signature.verify(sign);}private enum Mode {ENCRYPT(Cipher.ENCRYPT_MODE),DECRYPT(Cipher.DECRYPT_MODE);private final int value;Mode(int value) {this.value = value;}}private static byte[] doFinal(Key key, Mode mode, byte[] data) throws Exception {final int MAX = (mode == Mode.ENCRYPT) ? MAX_ENCRYPT_BLOCK : MAX_DECRYPT_BLOCK;final int LEN = data.length;byte[] cache;int i = 0, off = 0;ByteArrayOutputStream out = new ByteArrayOutputStream();Cipher cipher = Cipher.getInstance(ALGORITHM_RSA_PKCS1PADDING);cipher.init(mode.value, key);while (off < LEN) {cache = cipher.doFinal(data, off, Math.min(LEN - off, MAX));out.write(cache, 0, cache.length);i++;off = i * MAX;}byte[] result = out.toByteArray();out.close();return result;}}附RSAUtil.java测试代码:import java.security.KeyPair;import java.security.PrivateKey;import java.security.PublicKey;import java.util.Arrays;public class RSATest {public static void main(String[] args) throws Exception {KeyPair keyPair = RSAUtil.genKeyPair();PublicKey publicKey = keyPair.getPublic();PrivateKey privateKey = keyPair.getPrivate();System.err.println("公钥加密——私钥解密");String src = "第⼀次握⼿:Client将标志位SYN置为1,随机产⽣⼀个值seq=J,并将该数据包发送给Server,Client进⼊SYN_SENT状态,等待Server确认。

java国密加密与解密流程

java国密加密与解密流程下载温馨提示:该文档是我店铺精心编制而成,希望大家下载以后,能够帮助大家解决实际的问题。

文档下载后可定制随意修改,请根据实际需要进行相应的调整和使用,谢谢!并且,本店铺为大家提供各种各样类型的实用资料,如教育随笔、日记赏析、句子摘抄、古诗大全、经典美文、话题作文、工作总结、词语解析、文案摘录、其他资料等等,如想了解不同资料格式和写法,敬请关注!Download tips: This document is carefully compiled by theeditor. I hope that after you download them,they can help yousolve practical problems. The document can be customized andmodified after downloading,please adjust and use it according toactual needs, thank you!In addition, our shop provides you with various types ofpractical materials,such as educational essays, diaryappreciation,sentence excerpts,ancient poems,classic articles,topic composition,work summary,word parsing,copy excerpts,other materials and so on,want to know different data formats andwriting methods,please pay attention!1. 引入国密相关的依赖库在 Java 项目中,需要引入国密相关的依赖库,例如 Bouncy Castle 库。

SpringBoot生成License的实现示例

SpringBoot⽣成License的实现⽰例前⾔License指的是版权许可证,当我们开发完系统后,如果不想让⽤户⼀直⽩嫖使⽤,⽐如说按时间续费,License的作⽤就有了。

我们可以给系统指定License的有效期,控制系统的可⽤时间。

那么对于SpringBoot项⽬,如何增加License呢?接下来王⼦给⼤家带来⼀套解决⽅案。

(当然实现⽅式不⽌⼀种)⽣成License下载后打开cloud-license-serve项⽬直接启动即可。

会得到类似如下结果,分别代表ip地址、mac地址、cpu序号、主板序号。

{"ipAddress": ["192.168.80.1","192.168.220.1"],"macAddress": ["01-51-56-C0-00-01","00-52-56-C0-00-08","BC-54-2D-DF-69-FC"],"cpuSerial": "BFECFBFF000806EC","mainBoardSerial": "L1HF16301D5"}使⽤JDK⾃带的 keytool ⼯具⽣成公私钥证书库:假如我们设置公钥库密码为:public_password1234,私钥库密码为:private_password1234,则⽣成命令如下:#⽣成命令keytool -genkeypair -keysize 1024 -validity 3650 -alias "privateKey" -keystore "privateKeys.keystore" -storepass "public_password1234" -keypass "private_password1234" -dname "CN=localhost, OU=localhost, O=localhost, L=SH, ST=SH, C=CN" #导出命令keytool -exportcert -alias "privateKey" -keystore "privateKeys.keystore" -storepass "public_password1234" -file "certfile.cer"#导⼊命令keytool -import -alias "publicCert" -file "certfile.cer" -keystore "publicCerts.keystore" -storepass "public_password1234"上述命令执⾏完成之后,会在当前路径下⽣成三个⽂件,分别是:privateKeys.keystore、publicCerts.keystore、certfile.cer。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
相关文档
最新文档