Package sun.misc

Examples of sun.misc.BASE64Encoder


        switch (encodingType) {
            case BASE64:
                if (log.isDebugEnabled()) {
                    log.debug("base64 encoding on output ");
                }
                return new BASE64Encoder().encode(baos.toByteArray()).getBytes();
            case BIGINTEGER16:
                if (log.isDebugEnabled()) {
                    log.debug("BigInteger 16 encoding on output ");
                }
                return new BigInteger(baos.toByteArray()).toByteArray();
View Full Code Here


        System.arraycopy(str.getBytes(), 0, inputBytes, 0,
                str.getBytes().length);
        for (int i = 0; i < padlength; i += 8) {
            cipher.encrypt(inputBytes, i, cryptBytes, i);
        }
        return new BASE64Encoder().encode(cryptBytes);
    }
View Full Code Here

            return null;
        }              
    }

    public static String encodeString(String plainTextPassword) {
        BASE64Encoder encoder = new BASE64Encoder();
         try {
            byte[] cleartext = plainTextPassword.getBytes("UTF8");     
            Cipher cipher = Cipher.getInstance("DES");
            cipher.init(Cipher.ENCRYPT_MODE, key);
            return encoder.encode(cipher.doFinal(cleartext));
        }
        catch (Exception e) {
            e.printStackTrace();
            return "";
        }       
View Full Code Here

      out.println("");
      out.flush();

      // invia il file codificato come uuencode
      FileInputStream fis = new FileInputStream(f);
      new BASE64Encoder().encodeBuffer(fis, os);
      fis.close();

      out.println("");
    }

    for(int i = 0; i < ssupList.size(); i++)
    {
      StreamSupplier ss = (StreamSupplier) (ssupList.get(i));

      out.println("--" + boundaryID);
      out.println("Content-Type: " + ss.getMimeType(i));
      out.println("Content-Transfer-Encoding: base64");
      if(ss.isMimeInLine(i))
        out.println("Content-Disposition: in-line; filename=\"" + ss.getNomeFile(i) + "\"");
      else
        out.println("Content-Disposition: attachment; filename=\"" + ss.getNomeFile(i) + "\"");
      out.println("");
      out.flush();

      InputStream istr = ss.getInput(i);
      new BASE64Encoder().encodeBuffer(istr, os);
      ss.notifyDone(istr, i);

      out.println("");
    }
View Full Code Here

   */
  public static String encrypt(String str) {
    try {
      final Cipher cipher = Cipher.getInstance(CIPHER_TRANSFORMATION);
      cipher.init(Cipher.ENCRYPT_MODE, getKey());
      return new BASE64Encoder().encode(cipher.doFinal(str.getBytes(ENCODING)));
    }
    catch(final GeneralSecurityException gse) {
      throw new IllegalArgumentException("Encryption failed due to an unexpected security error: " + gse.getMessage(),
          gse);
    }
View Full Code Here

            cipher.init(Cipher.ENCRYPT_MODE, theKey);
            // 注意把字符串转换成字节需要指定编码方式,一般用此“UTF8”。
            byte[] plaintext = strPwd.getBytes("UTF8");
            ciphertext = cipher.doFinal(plaintext);

            BASE64Encoder enc = new BASE64Encoder();
            cipherString = enc.encode(ciphertext);
        } catch (Exception e) {
            cipherString = strPwd;
            System.err.println("加密方法StrTool.getEncryptStr()异常(Key值存在问题):\n"
                    + e.getMessage());
        }
View Full Code Here

    try {
      Cipher cipher = Cipher.getInstance("Desede/ECB/PKCS5Padding");
      cipher.init(Cipher.ENCRYPT_MODE, theKey);
      byte[] plaintext = strPwd.getBytes("UTF8");
      ciphertext = cipher.doFinal(plaintext);
      BASE64Encoder enc = new BASE64Encoder();
      cipherString = enc.encode(ciphertext);
    } catch (Exception e) {
      cipherString = strPwd;
      e.printStackTrace();
    }
View Full Code Here

    try {
      Cipher cipher = Cipher.getInstance("Desede/ECB/PKCS5Padding");
      cipher.init(Cipher.ENCRYPT_MODE, theKey);
      byte[] plaintext = strPwd.getBytes("UTF8");
      ciphertext = cipher.doFinal(plaintext);
      BASE64Encoder enc = new BASE64Encoder();
      cipherString = enc.encode(ciphertext);
    } catch (Exception e) {
      cipherString = strPwd;
      e.printStackTrace();
    }
View Full Code Here

            if (!file.canRead()) {
                handleException("Payload file " + payloadFileName + " does cannot be read");
            }
            byte[] bytes = LoadBalancerConfigUtil.getBytesFromFile(file);
            if (bytes != null) {
                BASE64Encoder encoder = new BASE64Encoder();
                userData = encoder.encode(bytes);
            }
        } catch (Exception e) {
            LoadBalancerConfigUtil.handleException("Cannot read data from payload file " +
                                                   payloadFileName, e);
View Full Code Here

  public static byte[] decode(String pValue) throws IOException {
    return (new BASE64Decoder()).decodeBuffer(pValue);
  }

  public static String encode(byte[] pValue) {
    return (new BASE64Encoder()).encode(pValue);
  }
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.