Java Code Examples for org.whispersystems.util.Base64#encodeBytes()

The following examples show how to use org.whispersystems.util.Base64#encodeBytes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PushServiceSocket.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private String getAuthorizationHeader(CredentialsProvider credentialsProvider) {
  try {
    String identifier = credentialsProvider.getUuid() != null ? credentialsProvider.getUuid().toString() : credentialsProvider.getE164();
    return "Basic " + Base64.encodeBytes((identifier + ":" + credentialsProvider.getPassword()).getBytes("UTF-8"));
  } catch (UnsupportedEncodingException e) {
    throw new AssertionError(e);
  }
}
 
Example 2
Source File: ResumableUploadSpec.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public String serialize() {
  ResumableUploads.ResumableUpload.Builder builder = ResumableUploads.ResumableUpload.newBuilder()
                                                                                     .setSecretKey(ByteString.copyFrom(getSecretKey()))
                                                                                     .setIv(ByteString.copyFrom(getIV()))
                                                                                     .setTimeout(getExpirationTimestamp())
                                                                                     .setCdnNumber(getCdnNumber())
                                                                                     .setCdnKey(getCdnKey())
                                                                                     .setLocation(getResumeLocation())
                                                                                     .setTimeout(getExpirationTimestamp());

  return Base64.encodeBytes(builder.build().toByteArray());
}
 
Example 3
Source File: PushServiceSocket.java    From libsignal-service-java with GNU General Public License v3.0 5 votes vote down vote up
private String getAuthorizationHeader(CredentialsProvider credentialsProvider) {
  try {
    String identifier = credentialsProvider.getUuid() != null ? credentialsProvider.getUuid().toString() : credentialsProvider.getE164();
    return "Basic " + Base64.encodeBytes((identifier + ":" + credentialsProvider.getPassword()).getBytes("UTF-8"));
  } catch (UnsupportedEncodingException e) {
    throw new AssertionError(e);
  }
}
 
Example 4
Source File: JsonGroupInfo.java    From signal-cli with GNU General Public License v3.0 5 votes vote down vote up
JsonGroupInfo(SignalServiceGroup groupInfo) {
    this.groupId = Base64.encodeBytes(groupInfo.getGroupId());
    if (groupInfo.getMembers().isPresent()) {
        this.members = new ArrayList<>(groupInfo.getMembers().get().size());
        for (SignalServiceAddress address : groupInfo.getMembers().get()) {
            this.members.add(address.getNumber().get());
        }
    }
    if (groupInfo.getName().isPresent()) {
        this.name = groupInfo.getName().get();
    }
    this.type = groupInfo.getType().toString();
}
 
Example 5
Source File: EncryptedPreferences.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
static private String encrypt(String key, byte[] value, MasterCipher masterCipher) {
  return Base64.encodeBytes(masterCipher.encrypt(value, key.getBytes(UTF_8)));
}
 
Example 6
Source File: AudioHash.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
public AudioHash(@NonNull AudioWaveFormData audioWaveForm) {
  this(Base64.encodeBytes(audioWaveForm.toByteArray()), audioWaveForm);
}
 
Example 7
Source File: NotAGroupMemberException.java    From signal-cli with GNU General Public License v3.0 4 votes vote down vote up
public NotAGroupMemberException(byte[] groupId, String groupName) {
    super("User is not a member in group: " + groupName + " (" + Base64.encodeBytes(groupId) + ")");
}
 
Example 8
Source File: GroupNotFoundException.java    From signal-cli with GNU General Public License v3.0 4 votes vote down vote up
public GroupNotFoundException(byte[] groupId) {
    super("Group not found: " + Base64.encodeBytes(groupId));
}
 
Example 9
Source File: KeyUtils.java    From signal-cli with GNU General Public License v3.0 4 votes vote down vote up
private static String getSecret(int size) {
    byte[] secret = getSecretBytes(size);
    return Base64.encodeBytes(secret);
}
 
Example 10
Source File: JsonGroupInfo.java    From signal-cli with GNU General Public License v3.0 4 votes vote down vote up
JsonGroupInfo(byte[] groupId) {
    this.groupId = Base64.encodeBytes(groupId);
}