Skip to content

bryancolligan/angular-urlsafe-base64

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

angular-urlsafe-base64

Angular implementation that matches Python's base64.urlsafe_b64encode and base64.urlsafe_b64decode

Installation

Bower

bower install angular-urlsafe-base64

Usage

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

Unicode

You can encode unicode strings using base64 as described here.

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

About

Angular implementation that matches Python's base64.urlsafe_b64encode and base64.urlsafe_b64decode

Resources

Stars

Watchers

Forks

Packages

No packages published