Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions runtime/runtime-core/api/runtime-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -2163,6 +2163,7 @@ public final class aws/smithy/kotlin/runtime/text/encoding/Base64Kt {
public static final fun encodeBase64 (Ljava/lang/String;)Ljava/lang/String;
public static final fun encodeBase64 ([B)[B
public static final fun encodeBase64String ([B)Ljava/lang/String;
public static final fun encodeBase64Url ([B)Ljava/lang/String;
}

public final class aws/smithy/kotlin/runtime/text/encoding/Encodable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ public fun String.encodeBase64(): String = encodeToByteArray().encodeBase64().de
*/
public fun ByteArray.encodeBase64String(): String = encodeBase64().decodeToString()

/**
* Encode [ByteArray] in base64url format (RFC 4648) as a [String]
*/
public fun ByteArray.encodeBase64Url(): String =
encodeBase64String()
.replace('+', '-')
.replace('/', '_')
.trimEnd('=')

Comment on lines +56 to +64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the stdlib API instead of implementing this ourselves? https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.io.encoding/-base64/-default/-url-safe.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I wasn't aware of that, yeah I think we can just use that API

/**
* Encode [ByteArray] in base64 format and UTF-8 character encoding.
*/
Expand Down
Loading