Java Code Examples for com.sun.org.apache.xerces.internal.impl.dv.util.Base64#encode()
The following examples show how to use
com.sun.org.apache.xerces.internal.impl.dv.util.Base64#encode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodeController.java From sanshanblog with Apache License 2.0 | 6 votes |
/** * 验证码 base64输出 很慢 并且会生成大量的对象 * @param response * @throws IOException */ @GetMapping("/codeValidate") public ResponseMsgVO getCode(HttpServletResponse response) throws IOException { ResponseMsgVO msgVO = new ResponseMsgVO(); String capText = captchaProducer.createText(); BufferedImage buffImg = captchaProducer.createImage(capText); response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); response.setContentType("image/png"); //生成一个codeID对应 在三分钟内有效 Long codeId=atomicLong.incrementAndGet(); redisTemplate.opsForValue().set(ConstanceCacheKey.CODE_ID_PREFIX+String.valueOf(codeId), capText,3, TimeUnit.MINUTES); //将图片转换为BASE64编码 ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(buffImg, "png", os); byte[] bytes = os.toByteArray(); String imageCode = "data:image/png;base64,"+Base64.encode(bytes); CodeValidateVO codeValidateVO = new CodeValidateVO(imageCode, codeId); return msgVO.buildOKWithData(codeValidateVO); }
Example 2
Source File: Signer.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
/** * A handy version of {@link #sign(HttpMethod, java.net.URI, LinkedListMultimap, * String, SignAlgorithm)}, generates base64 encoded sign result. */ public static String signToBase64(HttpMethod httpMethod, URI uri, LinkedListMultimap<String, String> httpHeaders, String secretAccessKeyId, SignAlgorithm algorithm) throws NoSuchAlgorithmException, InvalidKeyException { return Base64.encode(sign(httpMethod, uri, httpHeaders, secretAccessKeyId, algorithm)); }
Example 3
Source File: Base64BinaryDV.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example 4
Source File: Base64BinaryDV.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example 5
Source File: Base64BinaryDV.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example 6
Source File: Base64BinaryDV.java From JDKSourceCode1.8 with MIT License | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example 7
Source File: Base64BinaryDV.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example 8
Source File: Base64BinaryDV.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example 9
Source File: Base64BinaryDV.java From Bytecoder with Apache License 2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example 10
Source File: Base64BinaryDV.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example 11
Source File: Base64BinaryDV.java From hottub with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example 12
Source File: Base64BinaryDV.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example 13
Source File: Base64BinaryDV.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example 14
Source File: Image.java From galaxy-sdk-java with Apache License 2.0 | 4 votes |
public void setContent(byte[] content) throws IOException { checkContentLength(content == null ? 0 : content.length); this.rawContent = content; this.content = Base64.encode(content); }
Example 15
Source File: PNGInfo.java From mil-sym-java with Apache License 2.0 | 4 votes |
/** * * @param drawMode 0 - normal, 1 - center, 2 - square * @return */ public String toSVG(int drawMode) { String svg = "<svg></svg>"; if(_image != null) { int x = 0; int y = 0; int width = _image.getWidth(); int height = _image.getHeight(); int svgWidth = width; int svgHeight = height; if(width > 0 && height > 0) { String b64 = "data:image/png;base64," + Base64.encode(getImageAsByteArray()); if(drawMode == 0)//normal { svg = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" " + "width=\"" + width + "\" height=\"" + height + "\"><image x=\"0\" y=\"0\"" + " width=\"" + width + "\" height=\"" + height + "\" xlink:href=\"" + b64 + "\" /></svg>"; } else if(drawMode == 1)//center { if(_centerPoint.getY() > svgHeight - _centerPoint.getY()) { svgHeight = (int)(_centerPoint.getY() * 2.0); y=0; } else { svgHeight = (int)((svgHeight - _centerPoint.getY()) * 2); y = (int)((svgHeight / 2) - _centerPoint.getY()); } if(_centerPoint.getX() > svgWidth - _centerPoint.getX()) { svgWidth = (int)(_centerPoint.getX() * 2.0); x=0; } else { svgWidth = (int)((svgWidth - _centerPoint.getX()) * 2); x = (int)((svgWidth / 2) - _centerPoint.getX()); } svg = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" " + "width=\"" + svgWidth + "\" height=\"" + svgHeight + "\"><image x=\"" + x + "\" y=\"" + y + "\"" + " width=\"" + width + "\" height=\"" + height + "\" xlink:href=\"" + b64 + "\" /></svg>"; } else if(drawMode == 2)//square { int newSize = svgHeight; if(svgWidth > svgHeight) newSize = width; if(svgWidth < newSize) x = (int)((newSize - svgWidth)/2.0); if(svgHeight < newSize) y = (int)((newSize - svgHeight)/2.0); svg = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" " + "width=\"" + newSize + "\" height=\"" + newSize + "\"><image x=\"" + x + "\" y=\"" + y + "\"" + " width=\"" + width + "\" height=\"" + height + "\" xlink:href=\"" + b64 + "\" /></svg>"; } } } return svg; }