本文整理了Java中org.apache.commons.net.util.Base64.decodeBase64()
方法的一些代码示例,展示了Base64.decodeBase64()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.decodeBase64()
方法的具体详情如下:
包路径:org.apache.commons.net.util.Base64
类名称:Base64
方法名:decodeBase64
[英]Decodes a Base64 String into octets
[中]将Base64字符串解码为八位字节
代码示例来源:origin: deeplearning4j/nd4j
/**
* Create an ndarray from a base 64
* representation
* @param base64 the base 64 to convert
* @return the ndarray from base 64
* @throws IOException
*/
public static INDArray fromBase64(String base64) throws IOException {
byte[] arr = Base64.decodeBase64(base64);
ByteArrayInputStream bis = new ByteArrayInputStream(arr);
DataInputStream dis = new DataInputStream(bis);
INDArray predict = Nd4j.read(dis);
return predict;
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Returns a set of arrays
* from base 64 that is tab delimited.
* @param base64 the base 64 that's tab delimited
* @return the set of arrays
*/
public static INDArray[] arraysFromBase64(String base64) throws IOException {
String[] base64Arr = base64.split("\t");
INDArray[] ret = new INDArray[base64Arr.length];
for (int i = 0; i < base64Arr.length; i++) {
byte[] decode = Base64.decodeBase64(base64Arr[i]);
ByteArrayInputStream bis = new ByteArrayInputStream(decode);
DataInputStream dis = new DataInputStream(bis);
INDArray predict = Nd4j.read(dis);
ret[i] = predict;
}
return ret;
}
代码示例来源:origin: commons-net/commons-net
/**
* Decodes a byte64-encoded integer according to crypto standards such as W3C's XML-Signature
*
* @param pArray
* a byte array containing base64 character data
* @return A BigInteger
* @since 1.4
*/
public static BigInteger decodeInteger(byte[] pArray) {
return new BigInteger(1, decodeBase64(pArray));
}
代码示例来源:origin: commons-net/commons-net
/**
* Parses the given ADAT response line and base64-decodes the data.
* @param reply The ADAT reply to parse.
* @return the data in the reply, base64-decoded.
* @since 3.0
*/
public byte[] parseADATReply(String reply)
{
if (reply == null) {
return null;
} else {
return Base64.decodeBase64(extractPrefixedData("ADAT=", reply));
}
}
代码示例来源:origin: pengwei1024/AndroidSourceViewer
byte[] bytes = Base64.decodeBase64(content);
FileUtils.write(outFile, new String(bytes), false);
} catch (IOException e) {
代码示例来源:origin: commons-net/commons-net
case CRAM_MD5:
byte[] serverChallenge = Base64.decodeBase64(getReplyString().substring(2).trim());
代码示例来源:origin: commons-net/commons-net
byte[] serverChallenge = Base64.decodeBase64(getReplyString().substring(2).trim());
代码示例来源:origin: commons-net/commons-net
byte[] serverChallenge = Base64.decodeBase64(getReplyString().substring(4).trim());
代码示例来源:origin: apache/eagle
public static byte[] decode(String input) {
return Base64.decodeBase64(input);
}
}
代码示例来源:origin: org.apache.eagle/eagle-common
public static byte[] decode(String input){
return Base64.decodeBase64(input);
}
}
代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-server
/**
* Decrypt a BASE64 encoded encrypted string.
*
* @param str BASE64 representation of encrypted string
* @return plain-text
*/
public static String decrypt(String str) {
try {
return new String(DECRYPTOR.doFinal(Base64.decodeBase64(str.getBytes("UTF-8"))));
} catch (Exception x) {
}
return null;
}
代码示例来源:origin: mustfun/mybatis-plus
public static PublicKey getPublicKey(String publicKeyText) {
if (publicKeyText == null || publicKeyText.length() == 0) {
publicKeyText = ConfigTools.DEFAULT_PUBLIC_KEY_STRING;
}
try {
byte[] publicKeyBytes = Base64.decodeBase64(publicKeyText);
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(
publicKeyBytes);
KeyFactory keyFactory = KeyFactory.getInstance("RSA", "SunRsaSign");
return keyFactory.generatePublic(x509KeySpec);
} catch (Exception e) {
throw new IllegalArgumentException("Failed to get public key", e);
}
}
代码示例来源:origin: mustfun/mybatis-plus
public static String encrypt(String key, String plainText) throws Exception {
if (key == null) {
key = DEFAULT_PRIVATE_KEY_STRING;
}
byte[] keyBytes = Base64.decodeBase64(key);
return encrypt(keyBytes, plainText);
}
代码示例来源:origin: hopshadoop/hopsworks
/**
*
* @param key
* @param ciphertext
* @return
* @throws Exception
*/
public static String decrypt(String key, String ciphertext, String masterEncryptionPassword)
throws Exception {
Cipher cipher = Cipher.getInstance("AES");
Key aesKey = generateKey(key, masterEncryptionPassword);
cipher.init(Cipher.DECRYPT_MODE, aesKey);
String decrypted = new String(cipher.doFinal(Base64.decodeBase64(ciphertext)));
return decrypted;
}
代码示例来源:origin: org.nd4j/nd4j-base64
/**
* Create an ndarray from a base 64
* representation
* @param base64 the base 64 to convert
* @return the ndarray from base 64
* @throws IOException
*/
public static INDArray fromBase64(String base64) throws IOException {
byte[] arr = Base64.decodeBase64(base64);
ByteArrayInputStream bis = new ByteArrayInputStream(arr);
DataInputStream dis = new DataInputStream(bis);
INDArray predict = Nd4j.read(dis);
return predict;
}
代码示例来源:origin: com.axway.ats.framework/ats-core
@Override
public int check( String host, byte[] key ) {
host = host.replace("[", "").replace("]", "").split(":")[0]; // get only the IP address of the server
if (knownHostsMap.get(host) == null) {
log.error("The presented trust store certificates could not match any of the server provided ones");
return HostKeyRepository.NOT_INCLUDED;
}
Set<byte[]> keys = knownHostsMap.get(host);
for (byte[] key1 : keys) {
key1 = Base64.decodeBase64(key1); // we must decode the key from the client trust store first
if (Arrays.equals(key, key1)) {
log.info("Server certificate trusted.");
return HostKeyRepository.OK;
}
}
log.error("The presented trust store certificates could not match any of the server provided ones");
return HostKeyRepository.NOT_INCLUDED;
}
代码示例来源:origin: com.centit.support/centit-utils
public static KeyPair keyPairFromJson(String keyJsonString) throws InvalidKeyException{
JSONObject keyJson = JSON.parseObject(keyJsonString);
return new KeyPair(
new RSAPublicKeyImpl(Base64.decodeBase64(keyJson.getString("public"))),
RSAPrivateCrtKeyImpl.newKey(
Base64.decodeBase64(keyJson.getString("private"))));
}
代码示例来源:origin: org.nd4j/nd4j-base64
/**
* Returns a set of arrays
* from base 64 that is tab delimited.
* @param base64 the base 64 that's tab delimited
* @return the set of arrays
*/
public static INDArray[] arraysFromBase64(String base64) throws IOException {
String[] base64Arr = base64.split("\t");
INDArray[] ret = new INDArray[base64Arr.length];
for (int i = 0; i < base64Arr.length; i++) {
byte[] decode = Base64.decodeBase64(base64Arr[i]);
ByteArrayInputStream bis = new ByteArrayInputStream(decode);
DataInputStream dis = new DataInputStream(bis);
INDArray predict = Nd4j.read(dis);
ret[i] = predict;
}
return ret;
}
代码示例来源:origin: mustfun/mybatis-plus
public static String decrypt(PublicKey publicKey, String cipherText)
throws Exception {
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
try {
cipher.init(Cipher.DECRYPT_MODE, publicKey);
} catch (InvalidKeyException e) {
// 因为 IBM JDK 不支持私钥加密, 公钥解密, 所以要反转公私钥
// 也就是说对于解密, 可以通过公钥的参数伪造一个私钥对象欺骗 IBM JDK
RSAPublicKey rsaPublicKey = (RSAPublicKey) publicKey;
RSAPrivateKeySpec spec = new RSAPrivateKeySpec(rsaPublicKey.getModulus(), rsaPublicKey.getPublicExponent());
Key fakePrivateKey = KeyFactory.getInstance("RSA").generatePrivate(spec);
cipher = Cipher.getInstance("RSA"); //It is a stateful object. so we need to get new one.
cipher.init(Cipher.DECRYPT_MODE, fakePrivateKey);
}
if (cipherText == null || cipherText.length() == 0) {
return cipherText;
}
byte[] cipherBytes = Base64.decodeBase64(cipherText);
byte[] plainBytes = cipher.doFinal(cipherBytes);
return new String(plainBytes);
}
代码示例来源:origin: MissionCriticalCloud/cosmic
public OptimiseFor getOptimiseFor() {
if (optimiseFor != null) {
if (getHttpMethod() == HTTPMethod.POST) {
optimiseFor = new String(Base64.decodeBase64(this.optimiseFor));
}
return OptimiseFor.valueOf(optimiseFor);
} else {
return OptimiseFor.Generic;
}
}
内容来源于网络,如有侵权,请联系作者删除!