Java Code Examples for org.whispersystems.signalservice.internal.util.Base64#encodeBytes()
The following examples show how to use
org.whispersystems.signalservice.internal.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: SignalServiceCipher.java From bcm-android with GNU General Public License v3.0 | 6 votes |
public OutgoingPushMessage encrypt(SignalProtocolAddress destination, byte[] unpaddedMessage, PushPurpose pushPurpose) throws UntrustedIdentityException { SessionCipher sessionCipher = new SessionCipher(signalProtocolStore, destination); PushTransportDetails transportDetails = new PushTransportDetails(sessionCipher.getSessionVersion()); CiphertextMessage message = sessionCipher.encrypt(transportDetails.getPaddedMessageBody(unpaddedMessage)); int remoteRegistrationId = sessionCipher.getRemoteRegistrationId(); String body = Base64.encodeBytes(message.serialize()); int type; switch (message.getType()) { case CiphertextMessage.PREKEY_TYPE: type = Type.PREKEY_BUNDLE_VALUE; break; case CiphertextMessage.WHISPER_TYPE: type = Type.CIPHERTEXT_VALUE; break; default: throw new AssertionError("Bad type: " + message.getType()); } return new OutgoingPushMessage(type, destination.getDeviceId(), remoteRegistrationId, body, pushPurpose); }
Example 2
Source File: JsonGroupInfo.java From signald with GNU General Public License v3.0 | 6 votes |
JsonGroupInfo(SignalServiceGroup groupInfo, String username) throws IOException, NoSuchAccountException { Manager manager = Manager.get(username); this.groupId = Base64.encodeBytes(groupInfo.getGroupId()); if (groupInfo.getMembers().isPresent()) { this.members = groupInfo.getMembers().get(); } if (groupInfo.getName().isPresent()) { this.name = groupInfo.getName().get(); } else { GroupInfo group = manager.getGroup(groupInfo.getGroupId()); if(group != null) { this.name = group.name; } } this.type = groupInfo.getType().toString(); }
Example 3
Source File: SignalBot.java From signal-bot with GNU General Public License v3.0 | 5 votes |
public void register(String username) throws IOException, BackingStoreException { logger.info("Sending verification SMS to " + username + "."); prefs.clear(); String password = Base64.encodeBytes(Util.getSecretBytes(18)); prefs.put("LOCAL_USERNAME", username); prefs.put("LOCAL_PASSWORD", password); accountManager = new SignalServiceAccountManager(config, username, password, USER_AGENT); accountManager.requestSmsVerificationCode(false); }
Example 4
Source File: JsonAttachment.java From signald with GNU General Public License v3.0 | 5 votes |
JsonAttachment(SignalServiceAttachment attachment, String username) throws IOException, NoSuchAccountException { this.contentType = attachment.getContentType(); final SignalServiceAttachmentPointer pointer = attachment.asPointer(); if (attachment.isPointer()) { this.id = pointer.getId(); this.key = Base64.encodeBytes(pointer.getKey()); if (pointer.getSize().isPresent()) { this.size = pointer.getSize().get(); } if(pointer.getPreview().isPresent()) { this.preview = Base64.encodeBytes(pointer.getPreview().get()); } if(pointer.getDigest().isPresent()) { this.digest = Base64.encodeBytes(pointer.getDigest().get()); } this.voiceNote = pointer.getVoiceNote(); this.width = pointer.getWidth(); this.height = pointer.getHeight(); if(pointer.getCaption().isPresent()) { this.caption = pointer.getCaption().get(); } if(pointer.getBlurHash().isPresent()) { this.blurhash = pointer.getBlurHash().get(); } File file = Manager.get(username).getAttachmentFile(pointer.getId()); if(file.exists()) { this.storedFilename = file.toString(); } } }
Example 5
Source File: JsonTypingMessage.java From signald with GNU General Public License v3.0 | 5 votes |
JsonTypingMessage(SignalServiceTypingMessage typingMessage) { action = typingMessage.getAction().name(); timestamp = typingMessage.getTimestamp(); if(typingMessage.getGroupId().isPresent()) { groupId = Base64.encodeBytes(typingMessage.getGroupId().get()); } }
Example 6
Source File: NotAGroupMemberException.java From signald with GNU General Public License v3.0 | 4 votes |
public NotAGroupMemberException(byte[] groupId, String groupName) { super("User is not a member in group: " + groupName + " (" + Base64.encodeBytes(groupId) + ")"); }
Example 7
Source File: GroupNotFoundException.java From signald with GNU General Public License v3.0 | 4 votes |
public GroupNotFoundException(byte[] groupId) { super("Group not found: " + Base64.encodeBytes(groupId)); }
Example 8
Source File: Util.java From signald with GNU General Public License v3.0 | 4 votes |
public static String getSecret(int size) { byte[] secret = getSecretBytes(size); return Base64.encodeBytes(secret); }
Example 9
Source File: JsonGroupInfo.java From signald with GNU General Public License v3.0 | 4 votes |
JsonGroupInfo(GroupInfo groupInfo, Manager m) { this.groupId = Base64.encodeBytes(groupInfo.groupId); this.name = groupInfo.name; this.members = new ArrayList<String>(groupInfo.members); this.avatarId = groupInfo.getAvatarId(); }
Example 10
Source File: AccountData.java From signald with GNU General Public License v3.0 | 4 votes |
public void setProfileKey(byte[] key) { if(key == null) { profileKey = ""; } profileKey = Base64.encodeBytes(key); }