Package sun.misc

Examples of sun.misc.BASE64Encoder.encode()


        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


            initKey();
            cipher.init(Cipher.ENCRYPT_MODE, skey, paramSpec);
            FileInputStream in = new FileInputStream(new File(inputFile));
            byte[] clearTextByte = readByte(new File(inputFile));
            BASE64Encoder encoder = new BASE64Encoder();
            String saltString = encoder.encode(SALT);
            String cipherTextString = encoder.encode(cipher.doFinal(clearTextByte));
            OutputStream cout = new FileOutputStream(outputFile);
            byte[] result = (saltString + cipherTextString).getBytes();
            cout.write(result);
            in.close();
View Full Code Here

            cipher.init(Cipher.ENCRYPT_MODE, skey, paramSpec);
            FileInputStream in = new FileInputStream(new File(inputFile));
            byte[] clearTextByte = readByte(new File(inputFile));
            BASE64Encoder encoder = new BASE64Encoder();
            String saltString = encoder.encode(SALT);
            String cipherTextString = encoder.encode(cipher.doFinal(clearTextByte));
            OutputStream cout = new FileOutputStream(outputFile);
            byte[] result = (saltString + cipherTextString).getBytes();
            cout.write(result);
            in.close();
            cout.close();
View Full Code Here

        System.out.println("Using alogrithm: " + digest.getAlgorithm());
        digest.reset();
        byte[] bytes = msg.getBytes();
        byte[] out = digest.digest(bytes);
        BASE64Encoder enc = new BASE64Encoder();
        System.out.println(enc.encode(out));
    }
}
View Full Code Here

        //TODO: Move this to the autoscale project
        File f = new File("/home/azeez/Desktop/axis2/payload.zip");
        try {
            byte[] bytes = getBytesFromFile(f);
            BASE64Encoder encoder = new BASE64Encoder();
            String userData = encoder.encode(bytes);
            data.setData(userData);
            System.out.println("Data=" + userData);
        } catch (IOException e) {
            e.printStackTrace();
        }
View Full Code Here

    public UserData getAppUserData() throws EC2Exception {
        UserData userData = new UserData();
        try {
            byte[] bytes = AutoscaleUtil.getBytesFromFile(new File(pApplicationPayload));
            BASE64Encoder encoder = new BASE64Encoder();
            String userDataStr = encoder.encode(bytes);
            userData.setData(userDataStr);
        } catch (IOException e) {
            autoscaleUtil.handleException("Cannot read data from payload file", e);
        }
        return userData;
View Full Code Here

    public UserData getLoadBalancerUserData() throws EC2Exception {
        UserData userData = new UserData();
        try {
            byte[] bytes = AutoscaleUtil.getBytesFromFile(new File(pLoadBalancerPayload));
            BASE64Encoder encoder = new BASE64Encoder();
            String userDataStr = encoder.encode(bytes);
            userData.setData(userDataStr);
        } catch (IOException e) {
            autoscaleUtil.handleException("Cannot read data from payload file", e);
        }
        return userData;
View Full Code Here

        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

            // 注意把字符串转换成字节需要指定编码方式,一般用此“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

      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

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.