Giter VIP home page Giter VIP logo

base64's Issues

Improve performance

Lib began as a concise functional and very inefficient look at Base64. Since scala-js it's probably necessary to improve speed and reduce garbage production.

General approach will be to use some mutable data structures and direct array referencing.

Encoding is not compatible with Browser decoding

Hey, I compiled it to javascript using scala-js and if you do something like :

href = "data:application/octet-stream;base64," + data.stripMargin.getBytes.toBase64

Then the downloaded file ends with some incorrectly decoded characters, otherwise it is alright. So I suspect that the Webkit/Chrome decoding is not compatible with this base64 encoding...

Btw to make this scala-js compatible one just need to comment out the specs2 test suite (that doesn't compile to javascript) or rewrite it using some scala-js compliant testing framework like utest and add plugin :

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.0-M3")

and enable it :

lazy val base64 = (project in file(".")).enablePlugins(org.scalajs.sbtplugin.ScalaJSPlugin)

Release with latest scalajs 1.x?

Hi @marklister

I was wondering whether you could release a new version against the latest scalajs? It's actually luckily humming along if it weren't for those big upgrades :-)

Thanks a lot,
Tanju

Consider structures other than `Array[Byte]`

From #6 (@bblfish)

Perhaps there is an extra improvement you can add. Is it possible to abstract somewhat from an array? For example the JS seems to return a ArrayBuffer which I think can be turned into a java.nio.ByteBuffer using TypedArrayBufferBridge.

So it would be useful to have a method that could work with those elements and not just arrays. I am not yet quite sure what the best abstraction here would be... Certainly given that you don't need to change the source object, an Array is too precise.

There is some example code here using a ByteBuffer https://gist.github.com/mseddon/1cfcb0970272cac40497

Strict padding unnecessary -- causes JS interop problem

JS WebCrytpoAPI produces Base64URL encoded strings in jws mode.

See the code here to produce those
http://stackoverflow.com/questions/33642310/is-there-a-way-to-get-the-components-of-an-rsa-key-in-the-webcrypto-api

The following JS code does the trick to convert it

function encodeURL(str){
    return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, '');
}

function decodeUrl(str){
    str = (str + '===').slice(0, str.length + (str.length % 4));
    return str.replace(/-/g, '+').replace(/_/g, '/');
}

and then one can use window.atob

I tried the library here, but it gives an error

base64url

Thing to consider. There are more than one standards of base64. base64url, for example, is increasingly popular, because it makes embedding it in urls easier.

You may want to add support for base64url to your lib, unless you consider it too much bloat.

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.