SHA-256
// private static void encryption(String id) { // try { // // 生成密钥 // SecretKey secretKey = generateKey(); // // // 加密 // String encryptedText = encrypt(id, secretKey); // id = encryptedText; // // // 解密 // String decryptedText = decrypt(encryptedText, secretKey); // System.out.println("解密后的文本: " + decryptedText); // } catch (Exception e) { // e.printStackTrace(); // } // } // private String getChannelOrderId(Long channelOrderId) { // String id; // try { // MessageDigest md = MessageDigest.getInstance("SHA-256"); // byte[] bytes = md.digest(channelOrderId.toString().getBytes()); // StringBuilder sb = new StringBuilder(); // for (byte b : bytes) { // sb.append(String.format("%02x", b & 0xff)); // } // id = sb.toString(); // } catch (NoSuchAlgorithmException e) { // // 记录错误日志 // logger.error("Failed to generate SHA-256 hash for order ID: " + channelOrderId, e); // return null; // } // return id; // }