大佬教程收集整理的这篇文章主要介绍了如何加密我的密码 – Android Studio,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试了这个教程,但我没有得到它的工作.
https://gist.github.com/aogilvie/6267013#file-string_encrypt_decrypt-md
我希望有一个人可以帮助我 :(
public class AESCrypt { private static final String ALGORITHM = "AES"; private static final String KEY = "1Hbfh667adfDEJ78"; public static String encrypt(String value) throws Exception { Key key = generateKey(); Cipher cipher = Cipher.geTinstance(AESCrypt.ALGORITHM); cipher.init(Cipher.ENCRYPT_MODE,key); byte [] encryptedByteValue = cipher.doFinal(value.getBytes("utf-8")); String encryptedValue64 = Base64.encodeToString(encryptedByteValue,Base64.DEFAULT); return encryptedValue64; } public static String decrypt(String value) throws Exception { Key key = generateKey(); Cipher cipher = Cipher.geTinstance(AESCrypt.ALGORITHM); cipher.init(Cipher.DECRYPT_MODE,key); byte[] decryptedValue64 = Base64.decode(value,Base64.DEFAULT); byte [] decryptedByteValue = cipher.doFinal(decryptedValue64); String decryptedValue = new String(decryptedByteValue,"utf-8"); return decryptedValue; } private static Key generateKey() throws Exception { Key key = new SecretKeySpec(AESCrypt.KEY.getBytes(),AESCrypt.ALGORITHM); return key; } }
以上是大佬教程为你收集整理的如何加密我的密码 – Android Studio全部内容,希望文章能够帮你解决如何加密我的密码 – Android Studio所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。