From b47541c1f9526b3ef843b1b791267e9aa8422ebb Mon Sep 17 00:00:00 2001 From: Sascha Peilicke Date: Fri, 1 Jul 2022 08:38:57 +0200 Subject: [PATCH] Improve documentation --- README.md | 26 +++++++++++++++++++ build.gradle.kts | 4 +-- .../kotlin/saschpe/kase64/Base64UrlTest.kt | 1 + 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 346041e..1deb572 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ ![Maven Central](https://img.shields.io/maven-central/v/de.peilicke.sascha/kase64) [![Build Status](https://github.com/saschpe/kase64/workflows/Main%20CI/badge.svg)](https://github.com/saschpe/kase64/actions) ![badge-android](http://img.shields.io/badge/platform-android-brightgreen.svg?style=flat) +![badge-ios](http://img.shields.io/badge/platform-ios-brightgreen.svg?style=flat) ![badge-native](http://img.shields.io/badge/platform-native-lightgrey.svg?style=flat) ![badge-js](http://img.shields.io/badge/platform-js-yellow.svg?style=flat) ![badge-jvm](http://img.shields.io/badge/platform-jvm-orange.svg?style=flat) @@ -11,6 +12,11 @@ Base64 encoder/decoder for Kotlin/Multiplatform. Supports Android, iOS, JavaScript and plain JVM environments. +**Supported encodings** + +- [Standard (Rfc 4648 section 4)](https://www.ietf.org/rfc/rfc4648.html#section-4) +- [URL-safe (Rfc 4648 section 5)](https://www.ietf.org/rfc/rfc4648.html#section-5) + ## Download Artifacts are published to [Maven Central][maven-central]: @@ -25,6 +31,26 @@ dependencies { } ``` +## Usage + +Standard Base64 decoding and encoding: + +```kotlin +import saschpe.kase64.* + +val helloWorld = "SGVsbG8sIHdvcmxkIQ==".base64Decoded // "Hello, world!" +println("Hello, world!".base64Encoded) // Prints "SGVsbG8sIHdvcmxkIQ==" +``` + +URL-safe Base64 decoding and encoding: + +```kotlin +import saschpe.kase64.* + +val helloWorld = "SGVsbG8sIHdvcmxkIQ".base64UrlDecoded // "Hello, world!" +println("Hello, world!".base64UrlEncoded) // Prints "SGVsbG8sIHdvcmxkIQ" +``` + ## License Copyright 2022 Sascha Peilicke diff --git a/build.gradle.kts b/build.gradle.kts index 3defe1f..c686ef9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ plugins { - kotlin("jvm") version "1.6.21" + kotlin("jvm") version "1.6.21" apply false id("com.android.library") version "7.0.4" apply false - id("com.diffplug.spotless") version "6.5.1" + id("com.diffplug.spotless") version "6.7.2" id("com.github.ben-manes.versions") version "0.42.0" } diff --git a/kase64/src/commonTest/kotlin/saschpe/kase64/Base64UrlTest.kt b/kase64/src/commonTest/kotlin/saschpe/kase64/Base64UrlTest.kt index 2e46fb8..8bc6c74 100644 --- a/kase64/src/commonTest/kotlin/saschpe/kase64/Base64UrlTest.kt +++ b/kase64/src/commonTest/kotlin/saschpe/kase64/Base64UrlTest.kt @@ -55,6 +55,7 @@ class Base64UrlTest { assertEquals("Word", "V29yZA==".base64UrlDecoded) assertEquals("Hello", "SGVsbG8=".base64UrlDecoded) assertEquals("World!", "V29ybGQh".base64UrlDecoded) + assertEquals("Hello, world!", "SGVsbG8sIHdvcmxkIQ".base64UrlDecoded) assertEquals("Hello, world!", "SGVsbG8sIHdvcmxkIQ==".base64UrlDecoded) assertEquals( Encoding.Standard.alphabet,