app直播原始碼,android AES加密解密實現
app直播原始碼,android AES加密解密實現
import android.util.Base64; import android.util.Log; import java.security.Key; import javax.crypto.Cipher; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.DESedeKeySpec; import javax.crypto.spec.IvParameterSpec; /** * Created by Jane on 2017/10/10. */ public class CryptoTools { public static final String keyStr = "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4"; private static byte[] key= Base64.decode(keyStr.getBytes(),Base64.DEFAULT); private static byte[] keyiv = { 1, 2, 3, 4, 5, 6, 7, 8 }; /** * ECB加密,不要IV * @param data 明文 * @return Base64編碼的密文 * @throws Exception */ public static byte[] des3EncodeECB(byte[] data) throws Exception { Key deskey = null; DESedeKeySpec spec = new DESedeKeySpec(key); SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede"); deskey = keyfactory.generateSecret(spec); Cipher cipher = Cipher.getInstance("desede" + "/ECB/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, deskey); byte[] bOut = cipher.doFinal(data); return bOut; } /** * ECB解密,不要IV * @param data Base64編碼的密文 * @return 明文 * @throws Exception */ public static byte[] ees3DecodeECB(byte[] data) throws Exception { Key deskey = null; DESedeKeySpec spec = new DESedeKeySpec(key); SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede"); deskey = keyfactory.generateSecret(spec); Cipher cipher = Cipher.getInstance("desede" + "/ECB/PKCS5Padding"); Log.i("des", "decode init before"); cipher.init(Cipher.DECRYPT_MODE, deskey); Log.i("des", "decode init after" + new String(data,"UTF-8")); byte[] bOut = cipher.doFinal(data); Log.i("des", "decode doFinal after"); return bOut; } /** * CBC加密 * @param data 明文 * @return Base64編碼的密文 * @throws Exception */ public static byte[] des3EncodeCBC( byte[] data) throws Exception { Key deskey = null; DESedeKeySpec spec = new DESedeKeySpec(key); SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede"); deskey = keyfactory.generateSecret(spec); Cipher cipher = Cipher.getInstance("desede" + "/CBC/PKCS5Padding"); IvParameterSpec ips = new IvParameterSpec(keyiv); cipher.init(Cipher.ENCRYPT_MODE, deskey, ips); byte[] bOut = cipher.doFinal(data); return bOut; } /** * CBC解密 * @param data Base64編碼的密文 * @return 明文 * @throws Exception */ public static byte[] des3DecodeCBC(byte[] data) throws Exception { Key deskey = null; DESedeKeySpec spec = new DESedeKeySpec(key); SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede"); deskey = keyfactory.generateSecret(spec); Cipher cipher = Cipher.getInstance("desede" + "/CBC/PKCS5Padding"); IvParameterSpec ips = new IvParameterSpec(keyiv); cipher.init(Cipher.DECRYPT_MODE, deskey, ips); byte[] bOut = cipher.doFinal(data); return bOut; } } 加密: byte[] temp = CryptoTools.des3EncodeECB(getString(R.string.app_url_use).getBytes("UTF-8")); String message = new String(Base64.encode(temp, Base64.DEFAULT),"UTF-8"); 解密: byte[] tmpt = Base64.decode(getString(R.string.app_url_use).getBytes("UTF-8"), Base64.DEFAULT); tmpt = CryptoTools.ees3DecodeECB(tmpt); String str = new String(tmpt, "UTF-8");
以上就是app直播原始碼,android AES加密解密實現, 更多內容歡迎關注之後的文章
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2989602/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- AES 加密&解密加密解密
- AES加密解密加密解密
- 通過Go實現AES加密和解密工具Go加密解密
- AES CBC 加密解密加密解密
- app直播原始碼,Node.js實現密碼雜湊加密APP原始碼Node.js密碼加密
- AES線上加密解密-附AES128,192,256,CBC,CFB,ECB,OFB,PCBC各種加密解密原始碼加密解密原始碼
- AES實現財務資料的加密解密儲存加密解密
- python實現aes加密解密,RSA簽名和驗籤,RSA加密解密,並呼叫介面Python加密解密
- golang AES-CBC 加密解密Golang加密解密
- JAVA中AES加密和解密Java加密解密
- app直播原始碼如何實現直播間紅包功能APP原始碼
- python AES-CBC 加密解密Python加密解密
- Java AES加密和解密教程 - BaeldungJava加密解密
- AES位元組陣列加密解密流程陣列加密解密
- delphi加密C#解密(AES-256)加密C#解密
- PHP實現摩斯電碼加密解密PHP加密解密
- app直播原始碼,android實現帶下劃線的密碼輸入框APP原始碼Android密碼
- 使用OpenSSL替代MCrypt實現AES加解密解密
- 直播app原始碼,HTML + jQuery 實現輪播圖APP原始碼HTMLjQuery
- 直播系統app原始碼,Android studio 實現app登入註冊頁面APP原始碼Android
- iOS開發中AES的加密和解密iOS加密解密
- 介面加密傳輸設計及AES加解密程式碼DEMO加密解密
- 教育直播APP原生開發,成品原始碼無加密APP原始碼加密
- app直播商城原始碼,有哪些常用的加密方式APP原始碼加密
- VB實現AES(Rijndael)加密的方法加密
- Android資料加密之Aes加密Android加密
- 直播APP原始碼,直播系統推流SDK(Android)APP原始碼Android
- 直播APP原始碼實現直播流程上需要注意的內容APP原始碼
- Go 如何實現 PHP 的密碼加密解密GoPHP密碼加密解密
- aes加密解密原始碼,含 128、192、256位,cbc、cfb、ecb、ofb、pcbc模式加密解密原始碼模式
- AES加密 – iOS與Java的同步實現加密iOSJava
- AES加密演算法的JAVA實現加密演算法Java
- app直播原始碼,xml實現由上而下的顏色漸變APP原始碼XML
- 直播app原始碼,map實現購物車選擇功能APP原始碼
- 直播軟體原始碼,uniapp捲軸置頂實現原始碼APP
- 影片直播app原始碼,純css實現橫向滾動APP原始碼CSS
- AES加解密多版本(GO、JAVA、Python)實現解密GoJavaPython
- JavaScript前端和Java後端的AES加密和解密JavaScript前端後端加密解密