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