Package sun.misc

Examples of sun.misc.BASE64Encoder


    catch(UnsupportedEncodingException unsupportedEncodingException)
    {
    unsupportedEncodingException.printStackTrace();
    }//end of catch block
    byte raw[] = md.digest();
    String hash = (new BASE64Encoder()).encode(raw);
    return hash;
  }//end of encrypt(String plaintext)
View Full Code Here


    }

    private static String hashPassword(String password) throws NoSuchAlgorithmException {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        byte[] md5password = md5.digest( password.getBytes() );
        BASE64Encoder encoder = new BASE64Encoder();
        return encoder.encode( md5password );
    }
View Full Code Here

    }

    public static String base64Encode(String s) {
        try {
            byte sBytes[] = s.getBytes("UTF-8");
            BASE64Encoder encoder = new sun.misc.BASE64Encoder();
            return (encoder.encode(sBytes)).replaceAll("\\n", "").replaceAll("/", "_").replaceAll("\\+", "-").trim();
        } catch (UnsupportedEncodingException e) {
            log.error("This Java installation doesn't support UTF-8. Call Mulder");
            return s;
        }
    }
View Full Code Here

    assertEquals("<b>b</b>", Atom_0_3_Parser.getValue(elt));
  }

  public void testBase64Content() throws Exception {
    Element elt = new Element("summary");
    BASE64Encoder enc = new BASE64Encoder();
    elt.addContent(enc.encode("<b>b</b>".getBytes()));
    elt.setAttribute("mode", "base64");
    assertEquals("<b>b</b>", Atom_0_3_Parser.getValue(elt));
  }
View Full Code Here

     * @return String der verschluesselte Text mit BASE64 Kodierung.
     * @throws java.lang.Exception
     */
    public static String encrypt( String text, String algName ) throws Exception {

      BASE64Encoder encoder = null;
      MessageDigest md      = null;
      encoder = new BASE64Encoder();
      md = MessageDigest.getInstance(algName);
      md.reset();
      md.update(text.getBytes());
      return encoder.encode(md.digest());

    }
View Full Code Here

  public static String getMd5(String password){
    String str = "";
    if(password !=null && !password.equals("")){
      try {
        MessageDigest md = MessageDigest.getInstance("MD5");
        BASE64Encoder base = new BASE64Encoder();
        //加密后的字符串
        str = base.encode(md.digest(password.getBytes("utf-8")));
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    return str;
View Full Code Here

    } catch (UnsupportedEncodingException e) {
      throw new ControllerException(e.getMessage());
    }

    byte raw[] = md.digest(); //step 4
    String hash = (new BASE64Encoder()).encode(raw); //step 5
    return hash; //step 6
  }
View Full Code Here

        BufferedImage image = ImageIO.read(new File(filePath));
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
            ImageIO.write(image, type, bos);
            byte[] imageBytes = bos.toByteArray();

            BASE64Encoder encoder = new BASE64Encoder();
            imageString = encoder.encode(imageBytes);
        //    Base64.encodeBase64String(fileContent);
           

            bos.close();
        } catch (IOException e) {
View Full Code Here

  }

  public void setMaiSubject(String paramString) throws MessagingException {
    try {
      this.maiSubject = paramString;
      BASE64Encoder localBASE64Encoder = new BASE64Encoder();
      this.message.setSubject("=?GBK?B?"
          + localBASE64Encoder.encode(paramString.getBytes()) + "?=");
    } catch (Exception localException) {
      localException.printStackTrace();
    }
  }
View Full Code Here

            connection.disconnect();
        }

        //Authenticate
        connection = (HttpURLConnection) new URL("http://localhost:8181" + contextPath).openConnection();
        String authentication = (new BASE64Encoder()).encode(("alan:starcraft").getBytes());
        connection.setRequestProperty("Authorization", "Basic " + authentication);
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
            assertEquals("Hello World", reader.readLine());
View Full Code Here

TOP

Related Classes of sun.misc.BASE64Encoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.