| | |
| | | package com.yeshi.buwan.util; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.io.UnsupportedEncodingException; |
| | | import com.google.gson.*; |
| | | |
| | | import javax.persistence.Entity; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.*; |
| | | import java.lang.reflect.Type; |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.text.DateFormat; |
| | | import java.util.Collection; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import javax.persistence.Entity; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.google.gson.*; |
| | | |
| | | import com.yeshi.buwan.domain.vip.VIPPriceType; |
| | | import sun.misc.BASE64Decoder; |
| | | import sun.misc.BASE64Encoder; |
| | | |
| | | /** |
| | | * @author Administrator |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | if (b != null) { |
| | | s = new BASE64Encoder().encode(b); |
| | | s = Base64.getEncoder().encodeToString(b); |
| | | } |
| | | return s; |
| | | } |
| | |
| | | |
| | | String s = null; |
| | | if (b != null) { |
| | | s = new BASE64Encoder().encode(b); |
| | | s = Base64.getEncoder().encodeToString(b); |
| | | } |
| | | return s; |
| | | } |
| | | |
| | | // 解密 |
| | | public static String getFromBase64(String s) { |
| | | byte[] b = null; |
| | | String result = null; |
| | | if (s != null) { |
| | | BASE64Decoder decoder = new BASE64Decoder(); |
| | | byte[] b = Base64.getDecoder().decode(s); |
| | | try { |
| | | b = decoder.decodeBuffer(s); |
| | | result = new String(b, "utf-8"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | |
| | | public static byte[] getFromBase64Byte(String s) { |
| | | byte[] b = null; |
| | | if (s != null) { |
| | | BASE64Decoder decoder = new BASE64Decoder(); |
| | | try { |
| | | b = decoder.decodeBuffer(s); |
| | | return b; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return null; |
| | | return Base64.getDecoder().decode(s); |
| | | } |
| | | |
| | | public static String getNumberFromString(String st) { |
| | |
| | | } |
| | | if (imgStr == null) // 图像数据为空 |
| | | return false; |
| | | BASE64Decoder decoder = new BASE64Decoder(); |
| | | try { |
| | | // Base64解码 |
| | | byte[] b = decoder.decodeBuffer(imgStr); |
| | | byte[] b = Base64.getDecoder().decode(imgStr); |
| | | for (int i = 0; i < b.length; ++i) { |
| | | if (b[i] < 0) {// 调整异常数据 |
| | | b[i] += 256; |
| | |
| | | out.close(); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |