Java实现密码、文件MD5加密,密码sha256、sha384、sha512Hex等加密


SHA512加密(参考:https://blog.csdn.net/zdj_Develop/article/details/89326621?utm_medium=distribute.pc_relevant.none-task-blog-baidulandingword-2&spm=1001.2101.3001.4242)

public static String encryptPasswordWithSHA512(String password) {
        try {
        MessageDigest messageDigest = MessageDigest.getInstance("SHA-512");  //创建SHA512类型的加密对象
        messageDigest.update(password.getBytes());
        byte[] bytes = messageDigest.digest();
        StringBuffer strHexString = new StringBuffer();
        for (int i = 0; i < bytes.length; i++) {
        String hex = Integer.toHexString(0xff & bytes[i]);
        if (hex.length() == 1) {
        strHexString.append('0');
        }
        strHexString.append(hex);
        }
        String result = strHexString.toString();
        return result;
        } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        return null;
        }
        }
       
其他加密 参考:
https://blog.csdn.net/xmt1139057136/article/details/88177934?utm_medium=distribute.pc_relevant.none-task-blog-baidulandingword-2&spm=1001.2101.3001.4242


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM