org.whispersystems.signalservice.internal.push.ByteArraySerializerBase64NoPadding.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signal-service-java Show documentation
Show all versions of signal-service-java Show documentation
Signal Service communication library for Java, unofficial fork
/*
* Copyright 2024 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.whispersystems.signalservice.internal.push
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.databind.JsonSerializer
import com.fasterxml.jackson.databind.SerializerProvider
import org.signal.core.util.Base64
/**
* JSON serializer to encode a ByteArray as a base64 string without padding.
*/
class ByteArraySerializerBase64NoPadding : JsonSerializer() {
override fun serialize(value: ByteArray, gen: JsonGenerator, serializers: SerializerProvider) {
gen.writeString(Base64.encodeWithoutPadding(value))
}
}