本文整理了Java中org.jivesoftware.smack.util.stringencoder.Base64.decode()
方法的一些代码示例,展示了Base64.decode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.decode()
方法的具体详情如下:
包路径:org.jivesoftware.smack.util.stringencoder.Base64
类名称:Base64
方法名:decode
暂无
代码示例来源:origin: igniterealtime/Smack
/**
* Create a HashElement from pre-calculated values.
* @param algorithm the algorithm that was used.
* @param hashB64 the checksum in base 64.
*/
public HashElement(HashManager.ALGORITHM algorithm, String hashB64) {
this.algorithm = algorithm;
this.hash = Base64.decode(hashB64);
this.hashB64 = hashB64;
}
代码示例来源:origin: igniterealtime/Smack
public byte[] getIncomingSoundBytes() {
return Base64.decode(incomingSound);
}
代码示例来源:origin: igniterealtime/Smack
public byte[] getOutgoingSoundBytes() {
return Base64.decode(outgoingSound);
}
代码示例来源:origin: igniterealtime/Smack
/**
* Return the byte representation of the avatar(if one exists), otherwise returns null if
* no avatar could be found.
* <b>Example 1</b>
* <pre>
* // Load Avatar from VCard
* byte[] avatarBytes = vCard.getAvatar();
*
* // To create an ImageIcon for Swing applications
* ImageIcon icon = new ImageIcon(avatar);
*
* // To create just an image object from the bytes
* ByteArrayInputStream bais = new ByteArrayInputStream(avatar);
* try {
* Image image = ImageIO.read(bais);
* }
* catch (IOException e) {
* e.printStackTrace();
* }
* </pre>
*
* @return byte representation of avatar.
*/
public byte[] getAvatar() {
if (photoBinval == null) {
return null;
}
return Base64.decode(photoBinval);
}
代码示例来源:origin: igniterealtime/Smack
public static final String decodeToString(byte[] input, int offset, int len) {
byte[] bytes = decode(input, offset, len);
try {
return new String(bytes, StringUtils.UTF8);
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("UTF-8 not supported", e);
}
}
代码示例来源:origin: igniterealtime/Smack
public static final String decodeToString(String string) {
byte[] bytes = decode(string);
try {
return new String(bytes, StringUtils.UTF8);
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("UTF-8 not supported", e);
}
}
代码示例来源:origin: igniterealtime/Smack
/**
* Returns the decoded data or null if data could not be decoded.
* <p>
* The encoded data is invalid if it contains bad Base64 input characters or
* if it contains the pad ('=') character on a position other than the last
* character(s) of the data. See <a
* href="http://xmpp.org/extensions/xep-0047.html#sec">XEP-0047</a> Section
* 6.
*
* @return the decoded data
*/
public byte[] getDecodedData() {
// return cached decoded data
if (this.decodedData != null) {
return this.decodedData;
}
// data must not contain the pad (=) other than end of data
if (data.matches(".*={1,2}+.+")) {
return null;
}
// decodeBase64 will return null if bad characters are included
this.decodedData = Base64.decode(data);
return this.decodedData;
}
代码示例来源:origin: igniterealtime/Smack
/**
* Return the HashMap of preKeys in the bundle.
* The map uses the preKeys ids as key and the preKeys as value.
*
* @return preKeys
*/
public HashMap<Integer, byte[]> getPreKeys() {
if (preKeys == null) {
preKeys = new HashMap<>();
for (int id : preKeysB64.keySet()) {
preKeys.put(id, Base64.decode(preKeysB64.get(id)));
}
}
return this.preKeys;
}
代码示例来源:origin: igniterealtime/Smack
/**
* Get the signature of the signedPreKey.
*
* @return signature as byte array
*/
public byte[] getSignedPreKeySignature() {
if (signedPreKeySignature == null) {
signedPreKeySignature = Base64.decode(signedPreKeySignatureB64);
}
return signedPreKeySignature.clone();
}
代码示例来源:origin: igniterealtime/Smack
private void setContentBinaryIfRequired() {
if (contentBinary == null) {
assert (StringUtils.isNotEmpty(contentString));
contentBinary = Base64.decode(contentString);
}
}
代码示例来源:origin: igniterealtime/Smack
/**
* Return the signedPreKey of the OmemoBundleElement.
*
* @return signedPreKey as byte array
*/
public byte[] getSignedPreKey() {
if (signedPreKey == null) {
signedPreKey = Base64.decode(signedPreKeyB64);
}
return this.signedPreKey.clone();
}
代码示例来源:origin: igniterealtime/Smack
/**
* Return the public identityKey of the bundles owner.
* This can be used to check the signedPreKeys signature.
* The fingerprint of this key is, what the user has to verify.
*
* @return public identityKey as byte array
*/
public byte[] getIdentityKey() {
if (identityKey == null) {
identityKey = Base64.decode(identityKeyB64);
}
return this.identityKey.clone();
}
代码示例来源:origin: igniterealtime/Smack
public static byte[] getAvatarBinary() {
return Base64.decode(getAvatarEncoded());
}
private static String getAvatarEncoded() {
代码示例来源:origin: igniterealtime/Smack
if (JivePropertiesManager.isJavaObjectEnabled()) {
try {
byte[] bytes = Base64.decode(valueText);
ObjectInputStream in = new ObjectInputStream(
new ByteArrayInputStream(bytes));
代码示例来源:origin: igniterealtime/Smack
keys.add(new OmemoKeyElement(Base64.decode(parser.nextText()), rid, prekey));
break;
case OmemoHeaderElement.ATTR_IV:
iv = Base64.decode(parser.nextText());
break;
case ATTR_PAYLOAD:
payload = Base64.decode(parser.nextText());
break;
代码示例来源:origin: igniterealtime/Smack
continue;
PGPPublicKeyRing keyRing = new PGPPublicKeyRing(Base64.decode(key.getDataElement().getB64Data()), new BcKeyFingerprintCalculator());
store.importPublicKey(getJid(), keyRing);
} catch (PubSubException.NotAPubSubNodeException | PubSubException.NotALeafNodeException |
代码示例来源:origin: igniterealtime/Smack
/**
* The server is challenging the SASL mechanism for the stanza he just sent. Send a
* response to the server's challenge.
*
* @param challengeString a base64 encoded string representing the challenge.
* @param finalChallenge true if this is the last challenge send by the server within the success stanza
* @throws SmackException exception
* @throws InterruptedException if the connection is interrupted
*/
public final void challengeReceived(String challengeString, boolean finalChallenge) throws SmackException, InterruptedException {
byte[] challenge = Base64.decode((challengeString != null && challengeString.equals("=")) ? "" : challengeString);
byte[] response = evaluateChallenge(challenge);
if (finalChallenge) {
return;
}
Response responseStanza;
if (response == null) {
responseStanza = new Response();
}
else {
responseStanza = new Response(Base64.encodeToString(response));
}
// Send the authentication to the server
connection.sendNonza(responseStanza);
}
代码示例来源:origin: igniterealtime/Smack
/**
* Decrypt a secret key backup and return the {@link PGPSecretKeyRing} contained in it.
* TODO: Return a PGPSecretKeyRingCollection instead?
*
* @param backup encrypted {@link SecretkeyElement} containing the backup
* @param backupCode passphrase for decrypting the {@link SecretkeyElement}.
* @return the
* @throws InvalidBackupCodeException in case the provided backup code is invalid.
* @throws IOException IO is dangerous.
* @throws PGPException PGP is brittle.
*/
public static PGPSecretKeyRing restoreSecretKeyBackup(SecretkeyElement backup, String backupCode)
throws InvalidBackupCodeException, IOException, PGPException {
byte[] encrypted = Base64.decode(backup.getB64Data());
byte[] decrypted;
try {
decrypted = PGPainless.decryptWithPassword(encrypted, new Passphrase(backupCode.toCharArray()));
} catch (IOException | PGPException e) {
throw new InvalidBackupCodeException("Could not decrypt secret key backup. Possibly wrong passphrase?", e);
}
return PGPainless.readKeyRing().secretKeyRing(decrypted);
}
}
代码示例来源:origin: igniterealtime/Smack
if (keys == null) {
byte[] saltedPassword = hi(saslPrep(password), Base64.decode(salt), iterations);
代码示例来源:origin: org.igniterealtime.smack/smack-core
public static final String decodeToString(String string) {
byte[] bytes = decode(string);
try {
return new String(bytes, StringUtils.UTF8);
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("UTF-8 not supported", e);
}
}
内容来源于网络,如有侵权,请联系作者删除!