Package sun.misc

Examples of sun.misc.BASE64Encoder.encode()


    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 );
    }

    public static void main(String[] args) throws IOException, NoSuchAlgorithmException {
        if( args.length < 3 ) {
            System.out.println("Usage: BasicWebAuthHandler <file> <user> <password>");
View Full Code Here


  }

  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));
  }

  public void testDescriptionSelectionSummaryOnly() {
View Full Code Here

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

    }
   
    /**
     * Errechnet den MD5-Code eines Strings<br>
View Full Code Here

        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

    public static void downloadUrl(final String url) throws IOException {
        final URL downloader = new URL(url);
        final URLConnection urlConnection = downloader.openConnection();
        if (null != downloader.getUserInfo()) {
            BASE64Encoder encoder = new BASE64Encoder();
            final String basicAuth = "Basic " + new String(encoder.encode(
                    downloader.getUserInfo().getBytes()));
            urlConnection.setRequestProperty("Authorization", basicAuth);
        }
        final BufferedReader inputStream = new BufferedReader(new InputStreamReader(
                urlConnection.getInputStream()));
View Full Code Here

         SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
         random.setSeed(System.currentTimeMillis());
         byte bytes[] = new byte[32];
         random.nextBytes(bytes);
         BASE64Encoder encoder = new BASE64Encoder();
         return encoder.encode(bytes);
      }
      catch (NoSuchAlgorithmException e)
      {
         throw new AssertionError(e);
      }
View Full Code Here

      }
     
      BASE64Encoder be = new BASE64Encoder();
     
//      System.out.println(resultString);
      return be.encode((username + "\0" + resultString).getBytes());
 
}
View Full Code Here

        private void encryprtString(JTextArea textArea1, JTextArea textArea2,
                File keyFile, Encrypter encrypter) throws Exception {
            byte[] resultText = encrypter
                    .encrypt(textArea1.getText().getBytes(), keyFile);
            BASE64Encoder encoder = new BASE64Encoder();
            textArea2.setText(new String(encoder.encode(resultText)));
        }

        private void decryprtString(JTextArea textArea1, JTextArea textArea2,
                File keyFile, Encrypter encrypter) throws Exception {
            BASE64Decoder decoder = new BASE64Decoder();
View Full Code Here

    public byte[] encrypt(byte[] clearText, File keyFile) {
        try {
            initKey();
            cipher.init(Cipher.ENCRYPT_MODE, skey, paramSpec);
            BASE64Encoder encoder = new BASE64Encoder();
            String saltString = encoder.encode(SALT);
            String cipherTextString = encoder.encode(cipher.doFinal(clearText));
            return (saltString + cipherTextString).getBytes();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.