当前位置: 首页>>代码示例>>Java>>正文


Java Base64.encode方法代码示例

本文整理汇总了Java中org.apache.axis.encoding.Base64.encode方法的典型用法代码示例。如果您正苦于以下问题:Java Base64.encode方法的具体用法?Java Base64.encode怎么用?Java Base64.encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.axis.encoding.Base64的用法示例。


在下文中一共展示了Base64.encode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encodeToString

import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
public static String encodeToString (byte[] in, int width) throws Exception {
	// return  Base64.encode(in);
	String raw = Base64.encode(in);
	if (width > 0) {
		StringBuffer buf = new StringBuffer();
		for (int i=0;i<raw.length();i++) {
			buf.append(raw.charAt(i));
			if (i > 0 && (i % 72 == 0))
				buf.append ("=\n");
		}
		return buf.toString();
	}
	else {
		return raw;
	}
}
 
开发者ID:NCAR,项目名称:dls-repository-stack,代码行数:17,代码来源:ContentUtils.java

示例2: getConnection

import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
private HttpURLConnection getConnection(URL url, int retries) throws IOException{
	HttpURLConnection res = null;
	for(int i=0;i<retries;i++){
		try{
			res = (HttpURLConnection)url.openConnection();
			
		    String val = user + ":" + password;
		    String encoding = Base64.encode(val.getBytes());
		    res.setRequestProperty ("Authorization", "Basic " + encoding);				
			
			break;
		}catch(IOException e){
			log.warn("Connect failed to: "+url+" - retrying...",e);
			if(i==retries-1){
				throw e;
			}
		}
	}
	return res;
}
 
开发者ID:DIA-NZ,项目名称:webcurator,代码行数:21,代码来源:OMSUploadUtil.java

示例3: signHeader

import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
/**
 * Sign the current header with the correct private key for this connection.
 * 
 * @param header - the header string ( canonical )
 * @return - the Base64 signed encoding for the header 
 * @throws Exception
 */
private String signHeader( String _header ) throws Exception 
{		
	Signature signature = null;
	
	try {	
		signature = Signature.getInstance( "SHA1withRSA" );
		
		signature.initSign( getPrivateKeyObject() );
		
		/* IMPORTANT!
		 * The header specified by :
		 * 
		 * POST <request_url>\n
		 * \n
		 * \n
		 * x-nsdl-date : <date>\n
		 * 
		 */
		_header = "POST " + getConnection() + "\n\n\n" +  _header + "\n";
		
		signature.update( _header.getBytes("UTF-8") );
		
		// System.out.println ( "header to be signed : [" + _header + "]" );
		
		return 
			Base64.encode( signature.sign() );
	} catch ( Exception e ) {			
		return 
			""; // NOTE : we'll let the NDR server reject the connection w/ no handle
	}
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:39,代码来源:NDRConnection.java

示例4: encode

import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
public static String encode(String text)
   {
if(text == null)
    return text;
try {
    return Base64.encode(text.getBytes());
}
catch (Throwable e) {
    return null;
}
   }
 
开发者ID:nomencurator,项目名称:taxonaut,代码行数:12,代码来源:Base64Codex.java

示例5: sign

import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
/**
 * Creates a signature based on the given parameters.
 * 
 * @param toSign A string to sign
 * @return A signature
 */
public String sign(String toSign) {
  // compute the hmac on input data bytes
  byte[] rawHmac = mac.doFinal(toSign.getBytes());

  // base64-encode the hmac
  return Base64.encode(rawHmac);
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:14,代码来源:HMACSigner.java

示例6: getCacheFolderName

import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
private String getCacheFolderName()
{
  SessionIF session = Session.getCurrentSession();
  String sessionId = session.getId();

  return Base64.encode(sessionId.getBytes());
}
 
开发者ID:terraframe,项目名称:geoprism,代码行数:8,代码来源:ReportItem.java

示例7: encode

import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
public static String encode(byte[] bs){
    return Base64.encode(bs);
}
 
开发者ID:1991wangliang,项目名称:lorne_core,代码行数:4,代码来源:Base64Utils.java

示例8: getSaveInfo

import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
@Override
public String getSaveInfo(File f, String name,
    HashMap<String, String> params, boolean minified) throws WsSrvException {
  return "{\"base64\":\"" + new String(Base64.encode(
                GenericUtils.readFile(f))) + "\"}";
}
 
开发者ID:osbitools,项目名称:OsBiToolsWs,代码行数:7,代码来源:IconFileInfo.java


注:本文中的org.apache.axis.encoding.Base64.encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。