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


Java Base64.decode方法代码示例

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


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

示例1: main

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException{
	String dirName="H:\\java\\ImageMatching-pHash(modified)\\src\\resources\\dataset";
	ByteArrayOutputStream baos = new ByteArrayOutputStream(1000);
	BufferedImage img = ImageIO.read(new File(dirName,"tempImage.jpg"));
	ImageIO.write(img, "jpg", baos);
	baos.flush();

	String base64String = Base64.encode(baos.toByteArray());
	baos.close();

	byte[] bytearray = Base64.decode(base64String);
               
               for(int i=0;i<bytearray.length;i++){
                   System.out.println(bytearray[i]);
               }
               
	BufferedImage imag = ImageIO.read(new ByteArrayInputStream(bytearray));
	ImageIO.write(imag, "jpg", new File(dirName,"snap.jpg"));
}
 
开发者ID:nowshad-sust,项目名称:ImageMatching-pHash,代码行数:20,代码来源:ConvertImage.java

示例2: user

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; //导入方法依赖的package包/类
public static Map.Entry<String, String> user(HttpContext httpContext, String realm) throws AuthenticationException {
    HttpHeaders httpHeaders = httpContext.getRequestHeaders();
    String auth = httpHeaders.get(HttpHeaders.Authorization);

    if (auth == null || !auth.startsWith("Basic ")) {
        throw new BasicAuthenticationException(realm);
    }

    auth = auth.substring("Basic ".length());
    auth = new String(Base64.decode(auth));

    String[] parts = auth.split(":");

    if (parts.length != 2) {
        throw new BasicAuthenticationException(realm);
    }
    return new AbstractMap.SimpleImmutableEntry<String, String>(parts[0], parts[1]);
}
 
开发者ID:bobisjan,项目名称:adaptive-restful-api,代码行数:19,代码来源:BasicAuthentication.java

示例3: getActualValue

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; //导入方法依赖的package包/类
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
    byte[] decoded = Base64.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "base64Binary"});

    return new XBase64(decoded);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:Base64BinaryDV.java

示例4: decrypt

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; //导入方法依赖的package包/类
public static String decrypt(String s) throws Exception
{
	SecretKeySpec key = new SecretKeySpec(keyBytes, ALGO);
	cipher = Cipher.getInstance(ALGO);
	cipher.init(Cipher.DECRYPT_MODE, key);
	byte[] b = Base64.decode(s);
	return new String(cipher.doFinal(b));
}
 
开发者ID:timitoc,项目名称:groupicture,代码行数:9,代码来源:Encryptor.java

示例5: checkSaltedHash

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; //导入方法依赖的package包/类
public static boolean checkSaltedHash(String text, String hash) {
    try {
        byte[] hashWithSaltBytes = Base64.decode(hash);
        byte[] saltBytes = new byte[hashWithSaltBytes.length - 32];
        System.arraycopy(hashWithSaltBytes, 32, saltBytes, 0, saltBytes.length);
        String expectedHash = saltedHash(text, saltBytes);
        return expectedHash.equals(hash);

    } catch (Exception e) {
        return false;
    }
}
 
开发者ID:timitoc,项目名称:groupicture,代码行数:13,代码来源:Encryptor.java

示例6: imageToByteArray

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; //导入方法依赖的package包/类
public static byte[] imageToByteArray(String imagePath)throws IOException{
    ByteArrayOutputStream baos = new ByteArrayOutputStream(1000);
    BufferedImage img = ImageIO.read(new File(imagePath));
    ImageIO.write(img, "jpg", baos);
    baos.flush();
 
    String base64String = Base64.encode(baos.toByteArray());
    baos.close();
 
    byte[] bytearray = Base64.decode(base64String);
    
    return bytearray;
}
 
开发者ID:nowshad-sust,项目名称:ImageMatching-pHash,代码行数:14,代码来源:ConvertImage.java

示例7: main

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; //导入方法依赖的package包/类
/**
 * Main startup method. Takes in 2 arguments, a Base64 JSON encoding and
 * a project root.
 *
 * @param args  [0]: A Base64 encoded JSON String containing
 *              keys for the branches and other details about
 *              the card. More information is found in the
 *              readme.
 *
 *              [1]: A project root dir. This should be where
 *              you would like the generated cards to be saved.
 *              If you want this to be relative, just use a '.'
 *              (period)
 */
public static void main(String[] args) throws IOException {
    String json = new String(Base64.decode(args[0]));
    File filebase = new File(args[1]);
    JsonObject project = new JsonParser().parse(json).getAsJsonObject();

    String title = project.get("title").getAsString();
    String repo = project.get("repo").getAsString();
    String repoName = project.get("repo_name").getAsString();
    ArrayList<Branch> branchList = new ArrayList<Branch>();
    HashMap<String, String> colours = new HashMap<String, String>();

    JsonArray branches = project.get("branches").getAsJsonArray();
    for (int i = 0; i < branches.size(); i++) {
        JsonObject branch = branches.get(i).getAsJsonObject();
        Branch b = new Branch();
        b.branchName = branch.get("branch").getAsString();
        b.buildNumber = branch.get("build").getAsString();
        b.buildStatus = branch.get("status").getAsString();
        if (!branch.get("duration").isJsonNull())
            b.duration = branch.get("duration").getAsInt();
        branchList.add(b);
    }

    if (project.has("colors")) {
        JsonObject colors = project.get("colors").getAsJsonObject();
        for (Map.Entry<String, JsonElement> element : colors.entrySet()) {
            colours.put(element.getKey(), element.getValue().getAsString());
        }
    }

    CardRenderer renderer = new CardRenderer(title, branchList, colours);
    File outDir = new File(filebase, "imgout/" + repo);
    outDir.mkdirs();
    ImageIO.write(renderer.render(), "png", new File(outDir, repoName + ".png"));
}
 
开发者ID:JacisNonsense,项目名称:TravisCards,代码行数:50,代码来源:BuildCards.java

示例8: decrypt

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; //导入方法依赖的package包/类
public String decrypt(String str, String hmpServerId, String vistaSystemId) throws BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException {
    if(!cinit) {
        cinit(hmpServerId, vistaSystemId);
    }
    byte[] encryptedBytes = Base64.decode(str);
    String decrypted = new String(decipher.doFinal(encryptedBytes));
    return decrypted;
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:9,代码来源:Main.java

示例9: fromString

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; //导入方法依赖的package包/类
/** Read the object from Base64 string. */
private static Object fromString( String s ) throws IOException, ClassNotFoundException {
     byte [] data = Base64.decode(s);
     ObjectInputStream ois = new ObjectInputStream( new ByteArrayInputStream(  data ) );
     Object o  = ois.readObject();
     ois.close();
     return o;
}
 
开发者ID:automenta,项目名称:netentionj-desktop,代码行数:9,代码来源:NLPClient.java

示例10: carregaCertificado

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; //导入方法依赖的package包/类
public X509Certificate carregaCertificado(){
	try {
		
		byte[] cert = Base64.decode(myCertificate);
		
		InputStream is = new ByteArrayInputStream(cert);
		
		CertificateFactory cf = CertificateFactory.getInstance("X509");
		X509Certificate x509 = (X509Certificate) cf.generateCertificate(is);
		
		is.close();
		
		return x509;
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
	
}
 
开发者ID:esaito,项目名称:ExemplosDemoiselle,代码行数:20,代码来源:CertificateSoftware.java


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