java 中使用Base64


    byte[] cipherData = Base64.encodeBase64(plainText.getBytes()); //默認不換行    
    byte[] cipherData = Base64.encodeBase64(plainText.getBytes(), false); //取消換行  
    byte[] cipherData = Base64.encodeBase64Chunked(plainText.getBytes()); //進行換行  
    String cipherText = Base64.encodeBase64String(plainText.getBytes()); //轉為字符串  

  2. 安全的url:轉換+為-、/為_、將多余的=去掉
Java代碼 

    byte[] cipherData = Base64.encodeBase64(plainText.getBytes(), false, true);  
    byte[] cipherData = Base64.encodeBase64URLSafe(plainText.getBytes());  
    String cipherText = Base64.encodeBase64URLSafeString(plainText.getBytes()); 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM