當前位置: 首頁>>代碼示例>>Java>>正文


Java Base64類代碼示例

本文整理匯總了Java中org.whispersystems.textsecure.internal.util.Base64的典型用法代碼示例。如果您正苦於以下問題:Java Base64類的具體用法?Java Base64怎麽用?Java Base64使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Base64類屬於org.whispersystems.textsecure.internal.util包,在下文中一共展示了Base64類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: encrypt

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
public OutgoingPushMessage encrypt(AxolotlAddress destination, byte[] unpaddedMessage) {
	SessionCipher sessionCipher = new SessionCipher(this.axolotlStore, destination);
	PushTransportDetails transportDetails = new PushTransportDetails(sessionCipher.getSessionVersion());
	CiphertextMessage message = sessionCipher.encrypt(transportDetails.getPaddedMessageBody(unpaddedMessage));
	int remoteRegistrationId = sessionCipher.getRemoteRegistrationId();
	String body = Base64.encodeBytes(message.serialize());
	byte type;
	switch(message.getType()) {
		case 2:
			type = 1;
			break;
		case 3:
			type = 3;
			break;
		default:
			throw new AssertionError("Bad type: " + message.getType());
	}

	return new OutgoingPushMessage(type, destination.getDeviceId(), remoteRegistrationId, body);
}
 
開發者ID:Agilitum,項目名稱:TextSecureSMP,代碼行數:21,代碼來源:TextSecureSMPCipher.java

示例2: deserialize

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
@Override
public byte[] deserialize(JsonElement jsonElement, Type type,
                          JsonDeserializationContext jsonDeserializationContext)
    throws JsonParseException
{
  try {
    return Base64.decodeWithoutPadding(jsonElement.getAsJsonPrimitive().getAsString());
  } catch (IOException e) {
    throw new JsonParseException(e);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:12,代碼來源:SignedPreKeyEntity.java

示例3: TextSecureEnvelope

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
public TextSecureEnvelope(String message, String signalingKey)
    throws IOException, InvalidVersionException
{
  byte[] ciphertext = Base64.decode(message);

  if (ciphertext.length < VERSION_LENGTH || ciphertext[VERSION_OFFSET] != SUPPORTED_VERSION)
    throw new InvalidVersionException("Unsupported version!");

  SecretKeySpec cipherKey  = getCipherKey(signalingKey);
  SecretKeySpec macKey     = getMacKey(signalingKey);

  verifyMac(ciphertext, macKey);

  this.signal = IncomingPushMessageSignal.parseFrom(getPlaintext(ciphertext, cipherKey));
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:16,代碼來源:TextSecureEnvelope.java

示例4: getCipherKey

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
private SecretKeySpec getCipherKey(String signalingKey) throws IOException {
  byte[] signalingKeyBytes = Base64.decode(signalingKey);
  byte[] cipherKey         = new byte[CIPHER_KEY_SIZE];
  System.arraycopy(signalingKeyBytes, 0, cipherKey, 0, cipherKey.length);

  return new SecretKeySpec(cipherKey, "AES");
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:8,代碼來源:TextSecureEnvelope.java

示例5: getMacKey

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
private SecretKeySpec getMacKey(String signalingKey) throws IOException {
  byte[] signalingKeyBytes = Base64.decode(signalingKey);
  byte[] macKey            = new byte[MAC_KEY_SIZE];
  System.arraycopy(signalingKeyBytes, CIPHER_KEY_SIZE, macKey, 0, macKey.length);

  return new SecretKeySpec(macKey, "HmacSHA256");
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:8,代碼來源:TextSecureEnvelope.java

示例6: getAuthorizationHeader

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
private String getAuthorizationHeader() {
  try {
    return "Basic " + Base64.encodeBytes((localNumber + ":" + password).getBytes("UTF-8"));
  } catch (UnsupportedEncodingException e) {
    throw new AssertionError(e);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:8,代碼來源:PushServiceSocket.java

示例7: deserialize

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
@Override
public ECPublicKey deserialize(JsonElement jsonElement, Type type,
                                JsonDeserializationContext jsonDeserializationContext)
    throws JsonParseException
{
  try {
    return Curve.decodePoint(Base64.decodeWithoutPadding(jsonElement.getAsJsonPrimitive().getAsString()), 0);
  } catch (InvalidKeyException | IOException e) {
    throw new JsonParseException(e);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:12,代碼來源:PreKeyEntity.java

示例8: deserialize

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
@Override
public IdentityKey deserialize(JsonElement jsonElement, Type type,
                               JsonDeserializationContext jsonDeserializationContext)
    throws JsonParseException
{
  try {
    return new IdentityKey(Base64.decodeWithoutPadding(jsonElement.getAsJsonPrimitive().getAsString()), 0);
  } catch (InvalidKeyException | IOException e) {
    throw new JsonParseException(e);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:12,代碼來源:PreKeyResponse.java

示例9: getAuthorizationHeader

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
private String getAuthorizationHeader() {
    try {
        return "Basic " + Base64.encodeBytes((localNumber + ":" + password).getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
        throw new AssertionError(e);
    }
}
 
開發者ID:Securecom,項目名稱:Securecom-Messaging,代碼行數:8,代碼來源:PushServiceSocket.java

示例10: serialize

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
@Override
public JsonElement serialize(byte[] signature, Type type,
                             JsonSerializationContext jsonSerializationContext)
{
  return new JsonPrimitive(Base64.encodeBytesWithoutPadding(signature));
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:7,代碼來源:SignedPreKeyEntity.java

示例11: OutgoingPushMessage

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
public OutgoingPushMessage(PushAddress address, PushBody body) {
  this.type                      = body.getType();
  this.destinationDeviceId       = address.getDeviceId();
  this.destinationRegistrationId = body.getRemoteRegistrationId();
  this.body                      = Base64.encodeBytes(body.getBody());
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:7,代碼來源:OutgoingPushMessage.java

示例12: serialize

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
@Override
public JsonElement serialize(ECPublicKey preKeyPublic, Type type,
                             JsonSerializationContext jsonSerializationContext)
{
  return new JsonPrimitive(Base64.encodeBytesWithoutPadding(preKeyPublic.serialize()));
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:7,代碼來源:PreKeyEntity.java

示例13: serialize

import org.whispersystems.textsecure.internal.util.Base64; //導入依賴的package包/類
@Override
public JsonElement serialize(IdentityKey identityKey, Type type,
                             JsonSerializationContext jsonSerializationContext)
{
  return new JsonPrimitive(Base64.encodeBytesWithoutPadding(identityKey.serialize()));
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:7,代碼來源:PreKeyResponse.java


注:本文中的org.whispersystems.textsecure.internal.util.Base64類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。