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


Java Base64.decode方法代码示例

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


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

示例1: deserialize

import net.iharder.Base64; //导入方法依赖的package包/类
@BotCommandHandler
private void deserialize(Message message, String content) throws IOException {
  outputChannel.set((TextChannel) message.getChannel());
  connectToFirstVoiceChannel(guild.getAudioManager());

  byte[] bytes = Base64.decode(content);

  MessageInput inputStream = new MessageInput(new ByteArrayInputStream(bytes));
  DecodedTrackHolder holder;

  while ((holder = manager.decodeTrack(inputStream)) != null) {
    if (holder.decodedTrack != null) {
      scheduler.addToQueue(holder.decodedTrack);
    }
  }
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:17,代码来源:MusicController.java

示例2: verify

import net.iharder.Base64; //导入方法依赖的package包/类
/**
 * 校验传入的plaintextbyte数组,与原加签的字符串验证运算是否验证通过.
 *
 * @param pubKeyBytes 公钥
 * @param plainText 待验证的字符串
 * @param signText 通过私钥数字签名后的密文(Base64编码)
 * @return true:验证通过 false:验证失败
 */
private static boolean verify(byte[] pubKeyBytes, String signText, String plainText) {

  try {
    // 取公钥匙对象
    PublicKey pubKey = RsaUtil.getPublicKey(pubKeyBytes);

    // 解密由base64编码的数字签名
    byte[] signed = Base64.decode(signText);
    Signature signatureChecker = Signature.getInstance("MD5withRSA");
    signatureChecker.initVerify(pubKey);
    signatureChecker.update(plainText.getBytes());

    // 验证签名是否正常
    return signatureChecker.verify(signed);
  } catch (Exception e) {
    throw new BaseSecurityException("E-BASE-SECURITY-000002").initCause(e);
  }
}
 
开发者ID:ibankapp,项目名称:ibankapp-base,代码行数:27,代码来源:SignProvider.java

示例3: decryptValue

import net.iharder.Base64; //导入方法依赖的package包/类
private static String decryptValue( final String value, final String key )
{
    try
    {
        if ( value == null || value.length() < 1 )
        {
            return "";
        }

        final SecretKey secretKey = makeKey( key );
        final byte[] decoded = Base64.decode( value, Base64.URL_SAFE | Base64.GZIP );
        final Cipher cipher = Cipher.getInstance( "AES" );
        cipher.init( Cipher.DECRYPT_MODE, secretKey );
        final byte[] decrypted = cipher.doFinal( decoded );
        return new String( decrypted );
    }
    catch ( Exception e )
    {
        final String errorMsg = "unexpected error performing helpdesk answer decrypt operation: " + e.getMessage();
        throw new IllegalArgumentException( errorMsg );
    }
}
 
开发者ID:ldapchai,项目名称:ldapchai,代码行数:23,代码来源:ChaiHelpdeskAnswer.java

示例4: testCDataNodes

import net.iharder.Base64; //导入方法依赖的package包/类
public void testCDataNodes() throws Exception {
    String text = "Text data -- left as it is";
    String textForBytes = "Byte data is automatically base64-encoded";
    String textEncoded = Base64.encodeBytes(textForBytes.getBytes("UTF-8"));

    BaseXMLBuilder builder = XMLBuilder_create("TestCDataNodes")
        .elem("CDataTextElem")
            .cdata(text)
            .up()
        .elem("CDataBytesElem")
            .cdata(textForBytes.getBytes("UTF-8"));

    Node cdataTextNode = builder.xpathFind("//CDataTextElem")
        .getElement().getChildNodes().item(0);
    assertEquals(Node.CDATA_SECTION_NODE, cdataTextNode.getNodeType());
    assertEquals(text, cdataTextNode.getNodeValue());

    Node cdataBytesNode = builder.xpathFind("//CDataBytesElem")
        .getElement().getChildNodes().item(0);
    assertEquals(Node.CDATA_SECTION_NODE, cdataBytesNode.getNodeType());
    assertEquals(textEncoded, cdataBytesNode.getNodeValue());
    String base64Decoded = new String(Base64.decode(cdataBytesNode.getNodeValue()));
    assertEquals(textForBytes, base64Decoded);
}
 
开发者ID:jmurty,项目名称:java-xmlbuilder,代码行数:25,代码来源:BaseXMLBuilderTests.java

示例5: parse

import net.iharder.Base64; //导入方法依赖的package包/类
public static Base64Value parse(String value) throws PersistenceException {
    try {
        return new Base64Value(Base64.decode(value));
    } catch (IOException e) {
        throw new PersistenceException("Cannot Base64-decode: " + value);
    }
}
 
开发者ID:erickok,项目名称:retrofit-xmlrpc,代码行数:8,代码来源:Base64Value.java

示例6: decodeBase64

import net.iharder.Base64; //导入方法依赖的package包/类
@Override
public byte[] decodeBase64(byte[] data) {
    try {
        return Base64.decode(data);
    } catch (IOException ex) {
        ex.printStackTrace();
    }
    return null;
}
 
开发者ID:jruesga,项目名称:rview,代码行数:10,代码来源:GerritApiClientTest.java

示例7: readPrivateKey

import net.iharder.Base64; //导入方法依赖的package包/类
/**
 * Read the private key from the file
 * 
 * @param is
 *            the InputStream for the key file
 * @return the PrivateKey
 */
@SneakyThrows
public static PrivateKey readPrivateKey(InputStream is) {
    byte[] keyBytes = Base64.decode(IoUtils.readBytes(is));
    PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
    KeyFactory kf = KeyFactory.getInstance(RSA_ALGORITHM);
    return kf.generatePrivate(spec);
}
 
开发者ID:polyglotted,项目名称:crypto-recipes,代码行数:15,代码来源:RsaKeyReader.java

示例8: readPublicKey

import net.iharder.Base64; //导入方法依赖的package包/类
/**
 * Read the public key from the file
 * 
 * @param is
 *            the InputStream for the key file
 * @return the PublicKey
 */
@SneakyThrows
public static PublicKey readPublicKey(InputStream is) {
    byte[] keyBytes = Base64.decode(IoUtils.readBytes(is));
    X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes);
    KeyFactory kf = KeyFactory.getInstance(RSA_ALGORITHM);
    return kf.generatePublic(spec);
}
 
开发者ID:polyglotted,项目名称:crypto-recipes,代码行数:15,代码来源:RsaKeyReader.java

示例9: decode

import net.iharder.Base64; //导入方法依赖的package包/类
public byte[] decode( String data )
{
  byte[] dataBytes = null;

  if ( data != null && !data.isEmpty() )
    try { dataBytes = Base64.decode( data ); }
    catch ( Exception ex ) 
    {
        logger.error("Failed to decode byte data: " + ex.getMessage(), ex);
    }

  return dataBytes;
}
 
开发者ID:it-innovation,项目名称:EXPERImonitor,代码行数:14,代码来源:EMByteWrapper.java

示例10: getByteArrayProperty

import net.iharder.Base64; //导入方法依赖的package包/类
private byte[] getByteArrayProperty(ObjectNode node, String property) {
    try {
        String string = JsonUtil.getString(node, property, null);
        if (string == null)
            return null;
        return Base64.decode(string);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:NGDATA,项目名称:hbase-indexer,代码行数:11,代码来源:IndexerDefinitionJsonSerDeser.java

示例11: getId

import net.iharder.Base64; //导入方法依赖的package包/类
@Override
protected I getId(JSONObject vertexObject) throws IOException {
  try {
    byte[] decodedWritable = Base64.decode(
        vertexObject.getString(JsonBase64VertexFormat.VERTEX_ID_KEY));
    DataInput input = new DataInputStream(
        new ByteArrayInputStream(decodedWritable));
    I vertexId = getConf().createVertexId();
    vertexId.readFields(input);
    return vertexId;
  } catch (JSONException e) {
    throw new IllegalArgumentException(
      "next: Failed to get vertex id", e);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:16,代码来源:JsonBase64VertexInputFormat.java

示例12: getValue

import net.iharder.Base64; //导入方法依赖的package包/类
@Override
protected V getValue(JSONObject vertexObject) throws IOException {
  try {
    byte[] decodedWritable = Base64.decode(
        vertexObject.getString(JsonBase64VertexFormat.VERTEX_VALUE_KEY));
    DataInputStream input = new DataInputStream(
        new ByteArrayInputStream(decodedWritable));
    V vertexValue = getConf().createVertexValue();
    vertexValue.readFields(input);
    return vertexValue;
  } catch (JSONException e) {
    throw new IllegalArgumentException(
      "next: Failed to get vertex value", e);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:16,代码来源:JsonBase64VertexInputFormat.java

示例13: base64decode

import net.iharder.Base64; //导入方法依赖的package包/类
@Nonnull
public static byte [] base64decode(@Nonnull final String text) throws IOException {
  return Base64.decode(text);
}
 
开发者ID:raydac,项目名称:netbeans-mmd-plugin,代码行数:5,代码来源:Utils.java

示例14: initialize

import net.iharder.Base64; //导入方法依赖的package包/类
/**
 * Initialize the Content Management System Interface
 */
@PostConstruct
public void initialize() {
    this.geoCodingEnabled = StringUtils.toBoolean(this.geoCodingEnabledStringValue, false);
    if (this.geoCodingEnabled) {
        log.info("Activating GeoCoding Service Provider Interface - Google Maps Rest Services Implementation.");

        log.info("Configured Allowed Requests Per Day:[" +
                ((this.geoCodingServiceProviderAllowedRequestsPerDay != null) &&
                        (this.geoCodingServiceProviderAllowedRequestsPerDay > 0) ?
                        this.geoCodingServiceProviderAllowedRequestsPerDay :
                        "OFF")
                + "]");

        log.info("Configured Allowed Requests Per Second:[" +
                ((this.geoCodingServiceProviderAllowedRequestsPerSecond != null) &&
                        (this.geoCodingServiceProviderAllowedRequestsPerSecond > 0) ?
                        this.geoCodingServiceProviderAllowedRequestsPerSecond :
                        "OFF")
                + "]");

        log.info("Configured Throttle Wait:[" +
                ((this.geoCodingServiceProviderThrottleSecondsWaitPerRequest != null) &&
                        (this.geoCodingServiceProviderThrottleSecondsWaitPerRequest > 0) ?
                        this.geoCodingServiceProviderThrottleSecondsWaitPerRequest + " seconds" :
                        "OFF")
                + "]");

        // Determine if I have a Signature or Not.
        if (StringUtils.isNotEmpty(this.geoCodingServiceProviderClientSignature)) {
            // Convert the key from 'web safe' base 64 to binary
            String keyString = this.geoCodingServiceProviderClientSignature.replace('-', '+');
            keyString = keyString.replace('_', '/');
            try {
                this.binaryClientSignature = Base64.decode(keyString);
            } catch (IOException ioe) {
                log.error("Base64 decoding Exception occurred for Client Signature, removing Client Information so GMap Requests will not be Signed!");
                this.geoCodingServiceProviderClientSignature = null;
                this.geoCodingServiceProviderClientId = null;
            }
        } else {
            log.warn("No Client Signature Supplied, GMap Requests will not be Signed!");
        }

        // ***********************************************
        // Now Prepare Internal Cache for all Geo
        // Queries

        //
        // TODO - Have Geo Coding service Provider use Memcached as Internal cache for Queries.
        //






        // Initialized.
        this.initialized = true;
    } else {
        log.info("GeoCoding Service Provider Interface has been Disabled.");

        this.initialized = false;
    }
}
 
开发者ID:jaschenk,项目名称:jeffaschenk-commons,代码行数:68,代码来源:GeoCodingServiceProviderImpl.java

示例15: decodeStringWithBase64

import net.iharder.Base64; //导入方法依赖的package包/类
/** Returns a string decoded from a base64 encoded string
 * @param stringToBeDecoded the string to be decoded with base64
 * @return the string which is decoded using base64, or null if an error occurs! 
 * @throws IOException */
public static String decodeStringWithBase64(String stringToBeDecoded) throws IOException {
	byte[] decodedBytes = Base64.decode(stringToBeDecoded);

	return new String(decodedBytes);
}
 
开发者ID:jeromewagener,项目名称:Soutils,代码行数:10,代码来源:Soutilities.java


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