Git Product home page Git Product logo

basecodecs.scala's Introduction

Summary

Base Codecs library in Scala (JVM, JS, Native)

Supported Codecs

RFC 4648: Base16, Base32, Base32Hex, Base64, Base64URLSafe Crockford’s Base32 Multibase’s Base2, Base8 Zooko’s Base32

Current shortcomings

  • Iffy support of padding
  • No support for Crockford’s Base32 checksum
  • Lacking support for Base10, Base36Lowercase, Base36Uppercase, BitcoinBase58, FlickerBase58

Quality

>95% coverage test with `sbt coverage “core3/test” coverageReport`

https://github.com/scoverage/sbt-scoverage

>99% Mutation score with `sbt “project core3” “stryker”`

https://stryker-mutator.io/docs/stryker4s/getting-started/

200,000 base64 encode/decode of 1KB per second on a single Zen 4 core with `sbt “core-bench3/Jmh/run dev.librecybernetics.data.Base64Bench”`

basecodecs.scala's People

Contributors

fabianhjr avatar

Stargazers

Davo avatar

Watchers

 avatar  avatar

basecodecs.scala's Issues

Avoid BoxesRunTime

Profiling shows biggest overhead currently is BoxesRunTime

This is being generated on FnBijections

   package dev.librecybernetics.data.alphabet;

import dev.librecybernetics.data.FnBijection;
import dev.librecybernetics.data.Bijection.;
import java.io.Serializable;
import java.lang.invoke.SerializedLambda;
import scala.MatchError;
import scala.runtime.BoxesRunTime;
import scala.runtime.ModuleSerializationProxy;

public final class RFC4648$ implements Serializable {
   public static final RFC4648$ MODULE$ = new RFC4648$();

   private RFC4648$() {
   }

   private Object writeReplace() {
      return new ModuleSerializationProxy(RFC4648$.class);
   }

   public FnBijection<Object, Object> base16Lowercase() {
      return .MODULE$.apply((x$1) -> {
         return base16Lowercase$$anonfun$1(BoxesRunTime.unboxToByte(x$1));
      }, (x$1) -> {
         return base16Lowercase$$anonfun$2(BoxesRunTime.unboxToChar(x$1));
      });
   }

   public FnBijection<Object, Object> base16Uppercase() {
      return .MODULE$.apply((x$1) -> {
         return base16Uppercase$$anonfun$1(BoxesRunTime.unboxToByte(x$1));
      }, (x$1) -> {
         return base16Uppercase$$anonfun$2(BoxesRunTime.unboxToChar(x$1));
      });
   }

   public FnBijection<Object, Object> base32HexLowercase() {
      return .MODULE$.apply((x$1) -> {
         return base32HexLowercase$$anonfun$1(BoxesRunTime.unboxToByte(x$1));
      }, (x$1) -> {
         return base32HexLowercase$$anonfun$2(BoxesRunTime.unboxToChar(x$1));
      });
   }

   public FnBijection<Object, Object> base32HexUppercase() {
      return .MODULE$.apply((x$1) -> {
         return base32HexUppercase$$anonfun$1(BoxesRunTime.unboxToByte(x$1));
      }, (x$1) -> {
         return base32HexUppercase$$anonfun$2(BoxesRunTime.unboxToChar(x$1));
      });
   }

   public FnBijection<Object, Object> base32Lowercase() {
      return .MODULE$.apply((x$1) -> {
         return base32Lowercase$$anonfun$1(BoxesRunTime.unboxToByte(x$1));
      }, (x$1) -> {
         return base32Lowercase$$anonfun$2(BoxesRunTime.unboxToChar(x$1));
      });
   }

   public FnBijection<Object, Object> base32Uppercase() {
      return .MODULE$.apply((x$1) -> {
         return base32Uppercase$$anonfun$1(BoxesRunTime.unboxToByte(x$1));
      }, (x$1) -> {
         return base32Uppercase$$anonfun$2(BoxesRunTime.unboxToChar(x$1));
      });
   }

   public FnBijection<Object, Object> base64() {
      return .MODULE$.apply((x$1) -> {
         return base64$$anonfun$1(BoxesRunTime.unboxToByte(x$1));
      }, (x$1) -> {
         return base64$$anonfun$2(BoxesRunTime.unboxToChar(x$1));
      });
   }

   public FnBijection<Object, Object> base64URLSafe() {
      return .MODULE$.apply((x$1) -> {
         return base64URLSafe$$anonfun$1(BoxesRunTime.unboxToByte(x$1));
      }, (x$1) -> {
         return base64URLSafe$$anonfun$2(BoxesRunTime.unboxToChar(x$1));
      });
   }

   // $FF: synthetic method
   private static final char base16Lowercase$$anonfun$1(final byte x$1) {
      if (0 <= x$1 && x$1 <= 9) {
         return (char)(x$1 + 48);
      } else if (10 <= x$1 && x$1 <= 15) {
         return (char)(x$1 + 87);
      } else {
         throw new MatchError(BoxesRunTime.boxToByte(x$1));
      }
   }

   // $FF: synthetic method
   private static final byte base16Lowercase$$anonfun$2(final char x$1) {
      if ('0' <= x$1 && x$1 <= '9') {
         return (byte)(x$1 - 48);
      } else if ('a' <= x$1 && x$1 <= 'f') {
         return (byte)(x$1 - 87);
      } else {
         throw new MatchError(BoxesRunTime.boxToCharacter(x$1));
      }
   }

   // $FF: synthetic method
   private static final char base16Uppercase$$anonfun$1(final byte x$1) {
      if (0 <= x$1 && x$1 <= 9) {
         return (char)(x$1 + 48);
      } else if (10 <= x$1 && x$1 <= 15) {
         return (char)(x$1 + 55);
      } else {
         throw new MatchError(BoxesRunTime.boxToByte(x$1));
      }
   }

   // $FF: synthetic method
   private static final byte base16Uppercase$$anonfun$2(final char x$1) {
      if ('0' <= x$1 && x$1 <= '9') {
         return (byte)(x$1 - 48);
      } else if ('A' <= x$1 && x$1 <= 'F') {
         return (byte)(x$1 - 55);
      } else {
         throw new MatchError(BoxesRunTime.boxToCharacter(x$1));
      }
   }

   // $FF: synthetic method
   private static final char base32HexLowercase$$anonfun$1(final byte x$1) {
      if (10 <= x$1 && x$1 <= 31) {
         return (char)(x$1 + 87);
      } else if (0 <= x$1 && x$1 <= 9) {
         return (char)(x$1 + 48);
      } else {
         throw new MatchError(BoxesRunTime.boxToByte(x$1));
      }
   }

   // $FF: synthetic method
   private static final byte base32HexLowercase$$anonfun$2(final char x$1) {
      if ('a' <= x$1 && x$1 <= 'v') {
         return (byte)(x$1 - 87);
      } else if ('0' <= x$1 && x$1 <= '9') {
         return (byte)(x$1 - 48);
      } else {
         throw new MatchError(BoxesRunTime.boxToCharacter(x$1));
      }
   }

   // $FF: synthetic method
   private static final char base32HexUppercase$$anonfun$1(final byte x$1) {
      if (10 <= x$1 && x$1 <= 31) {
         return (char)(x$1 + 55);
      } else if (0 <= x$1 && x$1 <= 9) {
         return (char)(x$1 + 48);
      } else {
         throw new MatchError(BoxesRunTime.boxToByte(x$1));
      }
   }

   // $FF: synthetic method
   private static final byte base32HexUppercase$$anonfun$2(final char x$1) {
      if ('A' <= x$1 && x$1 <= 'V') {
         return (byte)(x$1 - 55);
      } else if ('0' <= x$1 && x$1 <= '9') {
         return (byte)(x$1 - 48);
      } else {
         throw new MatchError(BoxesRunTime.boxToCharacter(x$1));
      }
   }

   // $FF: synthetic method
   private static final char base32Lowercase$$anonfun$1(final byte x$1) {
      if (0 <= x$1 && x$1 <= 25) {
         return (char)(x$1 + 97);
      } else if (26 <= x$1 && x$1 <= 31) {
         return (char)(x$1 + 24);
      } else {
         throw new MatchError(BoxesRunTime.boxToByte(x$1));
      }
   }

   // $FF: synthetic method
   private static final byte base32Lowercase$$anonfun$2(final char x$1) {
      if ('a' <= x$1 && x$1 <= 'z') {
         return (byte)(x$1 - 97);
      } else if ('2' <= x$1 && x$1 <= '7') {
         return (byte)(x$1 - 24);
      } else {
         throw new MatchError(BoxesRunTime.boxToCharacter(x$1));
      }
   }

   // $FF: synthetic method
   private static final char base32Uppercase$$anonfun$1(final byte x$1) {
      if (0 <= x$1 && x$1 <= 25) {
         return (char)(x$1 + 65);
      } else if (26 <= x$1 && x$1 <= 31) {
         return (char)(x$1 + 24);
      } else {
         throw new MatchError(BoxesRunTime.boxToByte(x$1));
      }
   }

   // $FF: synthetic method
   private static final byte base32Uppercase$$anonfun$2(final char x$1) {
      if ('A' <= x$1 && x$1 <= 'Z') {
         return (byte)(x$1 - 65);
      } else if ('2' <= x$1 && x$1 <= '7') {
         return (byte)(x$1 - 24);
      } else {
         throw new MatchError(BoxesRunTime.boxToCharacter(x$1));
      }
   }

   // $FF: synthetic method
   private static final char base64$$anonfun$1(final byte x$1) {
      if (0 <= x$1 && x$1 <= 25) {
         return (char)(x$1 + 65);
      } else if (26 <= x$1 && x$1 <= 51) {
         return (char)(x$1 + 71);
      } else if (52 <= x$1 && x$1 <= 61) {
         return (char)(x$1 - 4);
      } else if (62 == x$1) {
         return '+';
      } else if (63 == x$1) {
         return '/';
      } else {
         throw new MatchError(BoxesRunTime.boxToByte(x$1));
      }
   }

   // $FF: synthetic method
   private static final byte base64$$anonfun$2(final char x$1) {
      if ('A' <= x$1 && x$1 <= 'Z') {
         return (byte)(x$1 - 65);
      } else if ('a' <= x$1 && x$1 <= 'z') {
         return (byte)(x$1 - 71);
      } else if ('0' <= x$1 && x$1 <= '9') {
         return (byte)(x$1 + 4);
      } else if ('+' == x$1) {
         return 62;
      } else if ('/' == x$1) {
         return 63;
      } else {
         throw new MatchError(BoxesRunTime.boxToCharacter(x$1));
      }
   }

   // $FF: synthetic method
   private static final char base64URLSafe$$anonfun$1(final byte x$1) {
      if (0 <= x$1 && x$1 <= 25) {
         return (char)(x$1 + 65);
      } else if (26 <= x$1 && x$1 <= 51) {
         return (char)(x$1 + 71);
      } else if (52 <= x$1 && x$1 <= 61) {
         return (char)(x$1 - 4);
      } else if (62 == x$1) {
         return '-';
      } else if (63 == x$1) {
         return '_';
      } else {
         throw new MatchError(BoxesRunTime.boxToByte(x$1));
      }
   }

   // $FF: synthetic method
   private static final byte base64URLSafe$$anonfun$2(final char x$1) {
      if ('A' <= x$1 && x$1 <= 'Z') {
         return (byte)(x$1 - 65);
      } else if ('a' <= x$1 && x$1 <= 'z') {
         return (byte)(x$1 - 71);
      } else if ('0' <= x$1 && x$1 <= '9') {
         return (byte)(x$1 + 4);
      } else if ('-' == x$1) {
         return 62;
      } else if ('_' == x$1) {
         return 63;
      } else {
         throw new MatchError(BoxesRunTime.boxToCharacter(x$1));
      }
   }

   // $FF: synthetic method
   private static Object $deserializeLambda$(SerializedLambda var0) {
      return Class.lambdaDeserialize<invokedynamic>(var0);
   }
}

From: https://www.decompiler.com/jar/b5d7d2b262084241859b4dfca805802c/RFC4648%24.java

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.