Hutool Hutool
(opens new window)
🏡首页
📖指南
  • 核心(Hutool-core)
  • 配置文件(Hutool-setting)
  • 日志(Hutool-log)
  • 缓存(Hutool-cache)
  • JSON(Hutool-json)
  • 加密解密(Hutool-crypto)
  • DFA查找(Hutool-dfa)
  • 数据库(Hutool-db)
  • HTTP客户端(Hutool-http)
  • 定时任务(Hutool-cron)
  • 扩展(Hutool-extra)
  • 布隆过滤(Hutool-bloomFilter)
  • 切面(Hutool-aop)
  • 脚本(Hutool-script)
  • Office文档操作(Hutool-poi)
  • 系统调用(Hutool-system)
  • 图形验证码(Hutool-captcha)
  • 网络Socket(Hutool-socket)
  • JWT(Hutool-jwt)
💡javaDoc (opens new window)
⏳更新记录 (opens new window)
  • 🍎gitee (opens new window)
  • 🍏github (opens new window)
(opens new window)
🏡首页
📖指南
  • 核心(Hutool-core)
  • 配置文件(Hutool-setting)
  • 日志(Hutool-log)
  • 缓存(Hutool-cache)
  • JSON(Hutool-json)
  • 加密解密(Hutool-crypto)
  • DFA查找(Hutool-dfa)
  • 数据库(Hutool-db)
  • HTTP客户端(Hutool-http)
  • 定时任务(Hutool-cron)
  • 扩展(Hutool-extra)
  • 布隆过滤(Hutool-bloomFilter)
  • 切面(Hutool-aop)
  • 脚本(Hutool-script)
  • Office文档操作(Hutool-poi)
  • 系统调用(Hutool-system)
  • 图形验证码(Hutool-captcha)
  • 网络Socket(Hutool-socket)
  • JWT(Hutool-jwt)
💡javaDoc (opens new window)
⏳更新记录 (opens new window)
  • 🍎gitee (opens new window)
  • 🍏github (opens new window)
  • 快速入门

  • 核心(Hutool-core)

  • 配置文件(Hutool-setting)

  • 日志(Hutool-log)

  • 缓存(Hutool-cache)

  • JSON(Hutool-json)

  • 加密解密(Hutool-crypto)

    • 概述
    • 加密解密工具-SecureUtil
    • 国密算法工具-SmUtil
    • 对称加密-SymmetricCrypto
    • 摘要加密-Digester
    • 消息认证码算法-HMac
    • 签名和验证-Sign
      • 介绍
      • 使用
    • 非对称加密-AsymmetricCrypto
  • DFA查找(Hutool-dfa)

  • 数据库(Hutool-db)

  • HTTP客户端(Hutool-http)

  • 定时任务(Hutool-cron)

  • 扩展(Hutool-extra)

  • 布隆过滤(Hutool-bloomFilter)

  • 切面(Hutool-aop)

  • 脚本(Hutool-script)

  • Office文档操作(Hutool-poi)

  • 系统调用(Hutool-system)

  • 图形验证码(Hutool-captcha)

  • 网络Socket(Hutool-socket)

  • JWT(Hutool-jwt)

  • 指南
  • 加密解密(Hutool-crypto)
Hutool
2023-03-28
目录

签名和验证-Sign

特别赞助 by:

# 介绍

Hutool针对java.security.Signature做了简化包装,包装类为:Sign,用于生成签名和签名验证。

对于签名算法,Hutool封装了JDK的Signature,具体介绍见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#Signature (opens new window):

// The RSA signature algorithm
NONEwithRSA

// The MD2/MD5 with RSA Encryption signature algorithm
MD2withRSA
MD5withRSA

// The signature algorithm with SHA-* and the RSA
SHA1withRSA
SHA256withRSA
SHA384withRSA
SHA512withRSA

// The Digital Signature Algorithm
NONEwithDSA

// The DSA with SHA-1 signature algorithm
SHA1withDSA

// The ECDSA signature algorithms
NONEwithECDSA
SHA1withECDSA
SHA256withECDSA
SHA384withECDSA
SHA512withECDSA

# 使用

byte[] data = "我是一段测试字符串".getBytes();
Sign sign = SecureUtil.sign(SignAlgorithm.MD5withRSA);
//签名
byte[] signed = sign.sign(data);
//验证签名
boolean verify = sign.verify(data, signed);
上次更新: 2025/05/06, 10:48:51
消息认证码算法-HMac
非对称加密-AsymmetricCrypto

← 消息认证码算法-HMac 非对称加密-AsymmetricCrypto→

Theme by Vdoing | Copyright © 2023-2025 Hutool | MulanPSL-2.0
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
×