本文实例总结了Android编程加密算法。分享给大家供大家参考,具体如下:
android常用加密算法之Base64加密算法:
package com.long;/** * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://".getBytes(); //加密 cipher.init(Cipher.ENCRYPT_MODE, publicKey); byte[] enBytes = cipher.doFinal(plainText); //通过密钥字符串得到密钥 publicKey = getPublicKey(publicKeyString); privateKey = getPrivateKey(privateKeyString); //解密 cipher.init(Cipher.DECRYPT_MODE, privateKey); byte[]deBytes = cipher.doFinal(enBytes); publicKeyString = getKeyString(publicKey); System.out.println("public:\n" +publicKeyString); privateKeyString = getKeyString(privateKey); System.out.println("private:\n" + privateKeyString); String s = new String(deBytes); System.out.println(s); } }希望本文所述对大家Android程序设计有所帮助。