angular-base64

WebJar for angular-base64

License

License

MIT
Categories

Categories

Angular User Interface Web Frameworks
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

angular-base64
Last Version

Last Version

2.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

angular-base64
WebJar for angular-base64
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/ninjatronic/angular-base64

Download angular-base64

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/angular-base64/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>angular-base64</artifactId>
    <version>2.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/angular-base64/
implementation 'org.webjars.bower:angular-base64:2.0.5'
// https://jarcasting.com/artifacts/org.webjars.bower/angular-base64/
implementation ("org.webjars.bower:angular-base64:2.0.5")
'org.webjars.bower:angular-base64:jar:2.0.5'
<dependency org="org.webjars.bower" name="angular-base64" rev="2.0.5">
  <artifact name="angular-base64" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='angular-base64', version='2.0.5')
)
libraryDependencies += "org.webjars.bower" % "angular-base64" % "2.0.5"
[org.webjars.bower/angular-base64 "2.0.5"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.bower : angular jar [1.0.8,)

Project Modules

There are no modules declared in this project.

angular-base64

Encapsulation of Nick Galbreath's base64.js library for AngularJS

For Base64 encoding which supports UTF8 see angular-utf8-base64

Installation

Bower

bower install angular-base64

NB: The ngBase64 bower package is deprecated due to camel casing issues on case-sensitive file systems.

<script src="bower_components/angular-base64/angular-base64.js"></script>

NPM

npm i angular-base64

Usage

angular
    .module('myApp', ['base64'])
    .controller('myController', [
    
        '$base64', '$scope', 
        function($base64, $scope) {
        
            $scope.encoded = $base64.encode('a string');
            $scope.decoded = $base64.decode('YSBzdHJpbmc=');
    }]);

Requiring NPM module when using Browserify

angular
    .module('myApp', [ require('angular-base64') ])
    .controller('myController', [
        '$base64', '$scope',
        function($base64, $scope) {

        $scope.encoded = $base64.encode('a string');
        $scope.decoded = $base64.decode('YSBzdHJpbmc=');
    }]);

Unicode

You can encode unicode strings using base64 as described here.

angular
    .module('myApp', ['base64'])
    .controller('myUnicodeController', [
    
        '$base64', '$scope', 
        function($base64, $scope) {
        
            $scope.encoded = $base64.encode(unescape(encodeURIComponent('✓ a string')));
            $scope.decoded = decodeURIComponent(escape($base64.decode('4pyTIGEgc3RyaW5n')));
    }]);

URL Safety

If you want to transmit a base64 encoded string in a url you must make it "URL safe" by encoding it with encodeURIComponent.

var base64EncodedString = $base64.encode('a string');
var urlSafeBase64EncodedString = encodeURIComponent(base64EncodedString);

To decode the above string use decodeURIComponent, then decode.

var base64EncodedString = decodeURIComponent('YSBzdHJpbmc%3D');
var decodedString = $base64.decode(base64EncodedString);

Versions

Version
2.0.5
2.0.4
2.0.3