💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
1.为什么出现加密的过程: 就是因为防止信息被一些手段进行破解 2.如何自定义对信息进行加密处理 2.1借助于sun包 2.2 static{ Try{ KeyGenerator generator = KeyGenerator.getInstance(“DES”) Generator.init(new SecureRandom(Key_STR.getBytes())) Key = generator.geneartekey(); generator =null }catch(Exceptipon o){ Throw new RuntimeException() } } //加密的方法 public static String getEncryptString(String str){ BASE64Encodeer base64Encoder = new BASE64Encoder(); try{ byte[] strbytes = str.getBytes(“UTF-8”) Cipjer cipher = Cipher.getInstance(“DES”) cipjer.init(Cipher.ENCRYPT_MODE,key) byte[] encryptStrBytes =cipher.doFinal() return base64Encoder.encode(encryptStrBytes) }catch(Exception e){ Throw new RuntimeException(); } } //解密的方法 public static String getDecryptString(String str){ BASE64Decoder base64Decoder = new BASE64Decoder(); Try{ byte[] strBytes = base64Decoder.decodeBuffer(str) Cipher cipher = Cipher.getInstance(“DES”) cipher.init(Cipher.DECRYPT_MODE,key) byte[] decryptStrBytes = cipher.doFinal(strBytes) return new String(decryptStrBytes,”UTF-8”) }catch(Exception e){ } }