Angular implementation that matches Python's base64.urlsafe_b64encode and base64.urlsafe_b64decode
bower install angular-urlsafe-base64
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=');
}]);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')));
}]);