Android编程加密算法小结(AES、Base64、RAS加密算法)

2019-12-10 19:52:17丽君

易采站长站为您分析Android编程加密算法,结合实例分析了AES、Base64及RAS加密算法,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例总结了Android编程加密算法。,具体如下:

android常用加密算法之Base64加密算法:

 

 
  1. package com.long;  /** 
  2. * Copyright (C) 2010 The Android Open Source Project  * 
  3. * Licensed under the Apache License, Version 2.0 (the "License");  * you may not use this file except in compliance with the License. 
  4. * You may obtain a copy of the License at  * 
  5. * http://www.easck.com/licenses/LICENSE-2.0  * 
  6. * Unless required by applicable law or agreed to in writing, software  * distributed under the License is distributed on an "AS IS" BASIS, 
  7. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  * See the License for the specific language governing permissions and 
  8. * limitations under the License.  */ 
  9. import java.io.ByteArrayOutputStream;  import java.io.IOException; 
  10. import java.io.OutputStream;  /* 
  11. * @author long  * 
  12. */  public class Base64 { 
  13. private static final char[] legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"  .toCharArray(); 
  14. public static String encode(byte[] data) {  int start = 0; 
  15. int len = data.length;  StringBuffer buf = new StringBuffer(data.length * 3 / 2); 
  16. int end = len - 3;  int i = start; 
  17. int n = 0;  while (i <= end) { 
  18. int d = ((((int) data[i]) & 0x0ff) << 16)  | ((((int) data[i + 1]) & 0x0ff) << 8)