All Projects → swift-extras → swift-extras-base64

swift-extras / swift-extras-base64

Licence: Apache-2.0 license
Base64 encode and decode without the use of Foundation in pure Swift.

Programming Languages

swift
15916 projects
shell
77523 projects
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to swift-extras-base64

BeFoR64
BeFoR64, Base64 encoding/decoding library for FoRtran poor men
Stars: ✭ 17 (-73.85%)
Mutual labels:  base64
convey
CSV processing and web related data types mutual conversion
Stars: ✭ 16 (-75.38%)
Mutual labels:  base64
vue-base64-file-upload
Upload files as base64 data-uris
Stars: ✭ 77 (+18.46%)
Mutual labels:  base64
swift-nio-redis
A high performance Redis protocol (RESP) implementation for SwiftNIO
Stars: ✭ 27 (-58.46%)
Mutual labels:  swift-server
tjson.js
JavaScript-compatible implementation of Tagged JSON (TJSON), written in TypeScript.
Stars: ✭ 53 (-18.46%)
Mutual labels:  base64
go-checksum
Simple tool to calc Golang module checksum of go.mod and module dir.
Stars: ✭ 45 (-30.77%)
Mutual labels:  base64
swift-lambda-runtime
⚠️ Deprecated AWS Lambda Runtime - please use https://github.com/swift-server/swift-aws-lambda-runtime instead
Stars: ✭ 68 (+4.62%)
Mutual labels:  swift-server
ImageSms
Image SMS uses long text SMS to send a very small picture.
Stars: ✭ 24 (-63.08%)
Mutual labels:  base64
universal-base64
Small universal base64 functions for node.js and browsers
Stars: ✭ 25 (-61.54%)
Mutual labels:  base64
data-encoding
Efficient and customizable data-encoding functions in Rust
Stars: ✭ 92 (+41.54%)
Mutual labels:  base64
Powershell-Obfuscator
Powerful script for logical obfuscation of powershell scripts
Stars: ✭ 27 (-58.46%)
Mutual labels:  base64
MicroExpress
A micro web server framework on top of Swift NIO
Stars: ✭ 125 (+92.31%)
Mutual labels:  swift-server
BaseNcoding
Library for encoding of binary data into strings using base32, base85, base128 and other algorithms.
Stars: ✭ 42 (-35.38%)
Mutual labels:  base64
base64.c
Base64 Library in C
Stars: ✭ 60 (-7.69%)
Mutual labels:  base64
Base62x
Base62x is an alternative approach to Base 64 without symbols in output.
Stars: ✭ 38 (-41.54%)
Mutual labels:  base64
redi-s
A performant Redis server implemented in SwiftNIO.
Stars: ✭ 69 (+6.15%)
Mutual labels:  swift-server
parcel-plugin-url-loader
📦url loader for parcel, use base64 encode file
Stars: ✭ 24 (-63.08%)
Mutual labels:  base64
pybase64
Fast Base64 encoding/decoding in Python
Stars: ✭ 84 (+29.23%)
Mutual labels:  base64
swift-server-app
Server app with Swift and Docker
Stars: ✭ 18 (-72.31%)
Mutual labels:  swift-server
react-file-input-previews-base64
This package provides an easy to use, ready to go and customizable wrapper around file input, with option for image previews and returning file as base64 string.
Stars: ✭ 15 (-76.92%)
Mutual labels:  base64

swift-extras-base64

Swift 5.1 github-actions codecov macOS tuxOS

This package provides a base64 encoder and decoder in Swift without the use of Foundation. The implementation is RFC4648 complient and is faster than the Foundation base64 implementation.

To achieve performance the implementation uses Chromium precomputed lookup tables and makes heavy use of unsafe swift API. When Swift has better support for SIMD instructions this might be an area worth exploring.

Status

  • support for base64 and base64url
  • faster than Foundation
  • padding can be omitted
  • decoding can ignore line breaks
  • encoding can insert line breaks

A former implementation of this package is used in swift-nio's websocket implementation.

Performance

Super simple performance test to ensure speediness of this implementation. Encoding and decoding 1m times the base64 string:

AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==

Tests were run on a MacBook Pro (16-inch, late 2019). Processor: 2.4 GHz 8-Core Intel Core i9.

macOS - swift 5.3

Encoding Decoding
Foundation 2.08s 2.15s
swift-extras-base64 0.66s 0.54s
Speedup 3x 4x

Linux - swift 5.3

Encoding Decoding
Foundation 1.01s 5.5s
swift-extras-base64 0.27s 0.41s
Speedup 3x ~10x

Literature for a faster algorithm

I would really like to speed up this project further to be way faster than it is today. Some food for thought of how this could be tackled can be found here:

Alternatives

As of today (2019-12-10), the author is aware of only one alternative that offers merely encoding.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].