convert a hexadecimal string to a Base64URL encoded string.
+convert a hexadecimal string to a Base64URL encoded string.
NOTE: If leading "0" is omitted and odd number length for
hexadecimal leading "0" is automatically added.
Defined in: base64x-1.1.js.
diff --git a/api/symbols/src/base64x-1.1.js.html b/api/symbols/src/base64x-1.1.js.html
index b5e16aa8..ddf191e5 100755
--- a/api/symbols/src/base64x-1.1.js.html
+++ b/api/symbols/src/base64x-1.1.js.html
@@ -5,14 +5,14 @@
.STRN {color: #393;}
.REGX {color: #339;}
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
-
1 /*! base64x-1.1.3 (c) 2012-2014 Kenji Urushima | kjur.github.com/jsjws/license
+ 1 /*! base64x-1.1.4 (c) 2012-2015 Kenji Urushima | kjur.github.com/jsjws/license
2 */
3 /*
4 * base64x.js - Base64url and supplementary functions for Tom Wu's base64.js library
5 *
- 6 * version: 1.1.3 (2014 May 25)
+ 6 * version: 1.1.4 (2015 Jul 3)
7 *
- 8 * Copyright (c) 2012-2014 Kenji Urushima (kenji.urushima@gmail.com)
+ 8 * Copyright (c) 2012-2015 Kenji Urushima (kenji.urushima@gmail.com)
9 *
10 * This software is licensed under the terms of the MIT License.
11 * http://kjur.github.com/jsjws/license/
@@ -25,376 +25,390 @@
18 */
19
20 /**
- 21 * Base64URL and supplementary functions for Tom Wu's base64.js library.<br/>
- 22 * This class is just provide information about global functions
- 23 * defined in 'base64x.js'. The 'base64x.js' script file provides
- 24 * global functions for converting following data each other.
- 25 * <ul>
- 26 * <li>(ASCII) String</li>
- 27 * <li>UTF8 String including CJK, Latin and other characters</li>
- 28 * <li>byte array</li>
- 29 * <li>hexadecimal encoded String</li>
- 30 * <li>Full URIComponent encoded String (such like "%69%94")</li>
- 31 * <li>Base64 encoded String</li>
- 32 * <li>Base64URL encoded String</li>
- 33 * </ul>
- 34 * All functions in 'base64x.js' are defined in {@link global__} and not
- 35 * in this class.
- 36 *
- 37 * @class Base64URL and supplementary functions for Tom Wu's base64.js library
- 38 * @author Kenji Urushima
- 39 * @version 1.1 (07 May 2012)
- 40 * @requires base64.js
- 41 * @see <a href="http://kjur.github.com/jsjws/">'jwjws'(JWS JavaScript Library) home page http://kjur.github.com/jsjws/</a>
- 42 * @see <a href="http://kjur.github.com/jsrsasigns/">'jwrsasign'(RSA Sign JavaScript Library) home page http://kjur.github.com/jsrsasign/</a>
- 43 */
- 44 function Base64x() {
- 45 }
- 46
- 47 // ==== string / byte array ================================
- 48 /**
- 49 * convert a string to an array of character codes
- 50 * @param {String} s
- 51 * @return {Array of Numbers}
+ 21 * @fileOverview
+ 22 * @name base64x-1.1.js
+ 23 * @author Kenji Urushima kenji.urushima@gmail.com
+ 24 * @version asn1 1.1.4 (2015-Jul-3)
+ 25 * @since jsrsasign 2.1
+ 26 * @license <a href="http://kjur.github.io/jsrsasign/license/">MIT License</a>
+ 27 */
+ 28
+ 29 /**
+ 30 * Base64URL and supplementary functions for Tom Wu's base64.js library.<br/>
+ 31 * This class is just provide information about global functions
+ 32 * defined in 'base64x.js'. The 'base64x.js' script file provides
+ 33 * global functions for converting following data each other.
+ 34 * <ul>
+ 35 * <li>(ASCII) String</li>
+ 36 * <li>UTF8 String including CJK, Latin and other characters</li>
+ 37 * <li>byte array</li>
+ 38 * <li>hexadecimal encoded String</li>
+ 39 * <li>Full URIComponent encoded String (such like "%69%94")</li>
+ 40 * <li>Base64 encoded String</li>
+ 41 * <li>Base64URL encoded String</li>
+ 42 * </ul>
+ 43 * All functions in 'base64x.js' are defined in {@link global__} and not
+ 44 * in this class.
+ 45 *
+ 46 * @class Base64URL and supplementary functions for Tom Wu's base64.js library
+ 47 * @author Kenji Urushima
+ 48 * @version 1.1 (07 May 2012)
+ 49 * @requires base64.js
+ 50 * @see <a href="http://kjur.github.com/jsjws/">'jwjws'(JWS JavaScript Library) home page http://kjur.github.com/jsjws/</a>
+ 51 * @see <a href="http://kjur.github.com/jsrsasigns/">'jwrsasign'(RSA Sign JavaScript Library) home page http://kjur.github.com/jsrsasign/</a>
52 */
- 53 function stoBA(s) {
- 54 var a = new Array();
- 55 for (var i = 0; i < s.length; i++) {
- 56 a[i] = s.charCodeAt(i);
- 57 }
- 58 return a;
- 59 }
- 60
- 61 /**
- 62 * convert an array of character codes to a string
- 63 * @param {Array of Numbers} a array of character codes
- 64 * @return {String} s
- 65 */
- 66 function BAtos(a) {
- 67 var s = "";
- 68 for (var i = 0; i < a.length; i++) {
- 69 s = s + String.fromCharCode(a[i]);
- 70 }
- 71 return s;
- 72 }
- 73
- 74 // ==== byte array / hex ================================
- 75 /**
- 76 * convert an array of bytes(Number) to hexadecimal string.<br/>
- 77 * @param {Array of Numbers} a array of bytes
- 78 * @return {String} hexadecimal string
- 79 */
- 80 function BAtohex(a) {
- 81 var s = "";
- 82 for (var i = 0; i < a.length; i++) {
- 83 var hex1 = a[i].toString(16);
- 84 if (hex1.length == 1) hex1 = "0" + hex1;
- 85 s = s + hex1;
- 86 }
- 87 return s;
- 88 }
- 89
- 90 // ==== string / hex ================================
- 91 /**
- 92 * convert a ASCII string to a hexadecimal string of ASCII codes.<br/>
- 93 * NOTE: This can't be used for non ASCII characters.
- 94 * @param {s} s ASCII string
- 95 * @return {String} hexadecimal string
- 96 */
- 97 function stohex(s) {
- 98 return BAtohex(stoBA(s));
- 99 }
-100
-101 // ==== string / base64 ================================
-102 /**
-103 * convert a ASCII string to a Base64 encoded string.<br/>
-104 * NOTE: This can't be used for non ASCII characters.
-105 * @param {s} s ASCII string
-106 * @return {String} Base64 encoded string
-107 */
-108 function stob64(s) {
-109 return hex2b64(stohex(s));
-110 }
-111
-112 // ==== string / base64url ================================
-113 /**
-114 * convert a ASCII string to a Base64URL encoded string.<br/>
-115 * NOTE: This can't be used for non ASCII characters.
-116 * @param {s} s ASCII string
-117 * @return {String} Base64URL encoded string
-118 */
-119 function stob64u(s) {
-120 return b64tob64u(hex2b64(stohex(s)));
-121 }
-122
-123 /**
-124 * convert a Base64URL encoded string to a ASCII string.<br/>
-125 * NOTE: This can't be used for Base64URL encoded non ASCII characters.
-126 * @param {s} s Base64URL encoded string
-127 * @return {String} ASCII string
-128 */
-129 function b64utos(s) {
-130 return BAtos(b64toBA(b64utob64(s)));
-131 }
-132
-133 // ==== base64 / base64url ================================
-134 /**
-135 * convert a Base64 encoded string to a Base64URL encoded string.<br/>
-136 * Example: "ab+c3f/==" → "ab-c3f_"
-137 * @param {String} s Base64 encoded string
-138 * @return {String} Base64URL encoded string
-139 */
-140 function b64tob64u(s) {
-141 s = s.replace(/\=/g, "");
-142 s = s.replace(/\+/g, "-");
-143 s = s.replace(/\//g, "_");
-144 return s;
-145 }
-146
-147 /**
-148 * convert a Base64URL encoded string to a Base64 encoded string.<br/>
-149 * Example: "ab-c3f_" → "ab+c3f/=="
-150 * @param {String} s Base64URL encoded string
-151 * @return {String} Base64 encoded string
-152 */
-153 function b64utob64(s) {
-154 if (s.length % 4 == 2) s = s + "==";
-155 else if (s.length % 4 == 3) s = s + "=";
-156 s = s.replace(/-/g, "+");
-157 s = s.replace(/_/g, "/");
-158 return s;
-159 }
-160
-161 // ==== hex / base64url ================================
-162 /**
-163 * convert a hexadecimal string to a Base64URL encoded string.<br/>
-164 * @param {String} s hexadecimal string
-165 * @return {String} Base64URL encoded string
-166 */
-167 function hextob64u(s) {
-168 return b64tob64u(hex2b64(s));
-169 }
-170
+ 53 function Base64x() {
+ 54 }
+ 55
+ 56 // ==== string / byte array ================================
+ 57 /**
+ 58 * convert a string to an array of character codes
+ 59 * @param {String} s
+ 60 * @return {Array of Numbers}
+ 61 */
+ 62 function stoBA(s) {
+ 63 var a = new Array();
+ 64 for (var i = 0; i < s.length; i++) {
+ 65 a[i] = s.charCodeAt(i);
+ 66 }
+ 67 return a;
+ 68 }
+ 69
+ 70 /**
+ 71 * convert an array of character codes to a string
+ 72 * @param {Array of Numbers} a array of character codes
+ 73 * @return {String} s
+ 74 */
+ 75 function BAtos(a) {
+ 76 var s = "";
+ 77 for (var i = 0; i < a.length; i++) {
+ 78 s = s + String.fromCharCode(a[i]);
+ 79 }
+ 80 return s;
+ 81 }
+ 82
+ 83 // ==== byte array / hex ================================
+ 84 /**
+ 85 * convert an array of bytes(Number) to hexadecimal string.<br/>
+ 86 * @param {Array of Numbers} a array of bytes
+ 87 * @return {String} hexadecimal string
+ 88 */
+ 89 function BAtohex(a) {
+ 90 var s = "";
+ 91 for (var i = 0; i < a.length; i++) {
+ 92 var hex1 = a[i].toString(16);
+ 93 if (hex1.length == 1) hex1 = "0" + hex1;
+ 94 s = s + hex1;
+ 95 }
+ 96 return s;
+ 97 }
+ 98
+ 99 // ==== string / hex ================================
+100 /**
+101 * convert a ASCII string to a hexadecimal string of ASCII codes.<br/>
+102 * NOTE: This can't be used for non ASCII characters.
+103 * @param {s} s ASCII string
+104 * @return {String} hexadecimal string
+105 */
+106 function stohex(s) {
+107 return BAtohex(stoBA(s));
+108 }
+109
+110 // ==== string / base64 ================================
+111 /**
+112 * convert a ASCII string to a Base64 encoded string.<br/>
+113 * NOTE: This can't be used for non ASCII characters.
+114 * @param {s} s ASCII string
+115 * @return {String} Base64 encoded string
+116 */
+117 function stob64(s) {
+118 return hex2b64(stohex(s));
+119 }
+120
+121 // ==== string / base64url ================================
+122 /**
+123 * convert a ASCII string to a Base64URL encoded string.<br/>
+124 * NOTE: This can't be used for non ASCII characters.
+125 * @param {s} s ASCII string
+126 * @return {String} Base64URL encoded string
+127 */
+128 function stob64u(s) {
+129 return b64tob64u(hex2b64(stohex(s)));
+130 }
+131
+132 /**
+133 * convert a Base64URL encoded string to a ASCII string.<br/>
+134 * NOTE: This can't be used for Base64URL encoded non ASCII characters.
+135 * @param {s} s Base64URL encoded string
+136 * @return {String} ASCII string
+137 */
+138 function b64utos(s) {
+139 return BAtos(b64toBA(b64utob64(s)));
+140 }
+141
+142 // ==== base64 / base64url ================================
+143 /**
+144 * convert a Base64 encoded string to a Base64URL encoded string.<br/>
+145 * Example: "ab+c3f/==" → "ab-c3f_"
+146 * @param {String} s Base64 encoded string
+147 * @return {String} Base64URL encoded string
+148 */
+149 function b64tob64u(s) {
+150 s = s.replace(/\=/g, "");
+151 s = s.replace(/\+/g, "-");
+152 s = s.replace(/\//g, "_");
+153 return s;
+154 }
+155
+156 /**
+157 * convert a Base64URL encoded string to a Base64 encoded string.<br/>
+158 * Example: "ab-c3f_" → "ab+c3f/=="
+159 * @param {String} s Base64URL encoded string
+160 * @return {String} Base64 encoded string
+161 */
+162 function b64utob64(s) {
+163 if (s.length % 4 == 2) s = s + "==";
+164 else if (s.length % 4 == 3) s = s + "=";
+165 s = s.replace(/-/g, "+");
+166 s = s.replace(/_/g, "/");
+167 return s;
+168 }
+169
+170 // ==== hex / base64url ================================
171 /**
-172 * convert a Base64URL encoded string to a hexadecimal string.<br/>
-173 * @param {String} s Base64URL encoded string
-174 * @return {String} hexadecimal string
-175 */
-176 function b64utohex(s) {
-177 return b64tohex(b64utob64(s));
-178 }
-179
-180 var utf8tob64u, b64utoutf8;
-181
-182 if (typeof Buffer === 'function')
-183 {
-184 utf8tob64u = function (s)
-185 {
-186 return b64tob64u(new Buffer(s, 'utf8').toString('base64'));
-187 };
-188
-189 b64utoutf8 = function (s)
-190 {
-191 return new Buffer(b64utob64(s), 'base64').toString('utf8');
-192 };
-193 }
-194 else
-195 {
-196 // ==== utf8 / base64url ================================
-197 /**
-198 * convert a UTF-8 encoded string including CJK or Latin to a Base64URL encoded string.<br/>
-199 * @param {String} s UTF-8 encoded string
-200 * @return {String} Base64URL encoded string
-201 * @since 1.1
-202 */
-203 utf8tob64u = function (s)
+172 * convert a hexadecimal string to a Base64URL encoded string.<br/>
+173 * @param {String} s hexadecimal string
+174 * @return {String} Base64URL encoded string
+175 * @description
+176 * convert a hexadecimal string to a Base64URL encoded string.
+177 * NOTE: If leading "0" is omitted and odd number length for
+178 * hexadecimal leading "0" is automatically added.
+179 */
+180 function hextob64u(s) {
+181 if (s.length % 2 == 1) s = "0" + s;
+182 return b64tob64u(hex2b64(s));
+183 }
+184
+185 /**
+186 * convert a Base64URL encoded string to a hexadecimal string.<br/>
+187 * @param {String} s Base64URL encoded string
+188 * @return {String} hexadecimal string
+189 */
+190 function b64utohex(s) {
+191 return b64tohex(b64utob64(s));
+192 }
+193
+194 var utf8tob64u, b64utoutf8;
+195
+196 if (typeof Buffer === 'function')
+197 {
+198 utf8tob64u = function (s)
+199 {
+200 return b64tob64u(new Buffer(s, 'utf8').toString('base64'));
+201 };
+202
+203 b64utoutf8 = function (s)
204 {
-205 return hextob64u(uricmptohex(encodeURIComponentAll(s)));
+205 return new Buffer(b64utob64(s), 'base64').toString('utf8');
206 };
-207
-208 /**
-209 * convert a Base64URL encoded string to a UTF-8 encoded string including CJK or Latin.<br/>
-210 * @param {String} s Base64URL encoded string
-211 * @return {String} UTF-8 encoded string
-212 * @since 1.1
-213 */
-214 b64utoutf8 = function (s)
-215 {
-216 return decodeURIComponent(hextouricmp(b64utohex(s)));
-217 };
-218 }
-219
-220 // ==== utf8 / base64url ================================
-221 /**
-222 * convert a UTF-8 encoded string including CJK or Latin to a Base64 encoded string.<br/>
-223 * @param {String} s UTF-8 encoded string
-224 * @return {String} Base64 encoded string
-225 * @since 1.1.1
-226 */
-227 function utf8tob64(s) {
-228 return hex2b64(uricmptohex(encodeURIComponentAll(s)));
-229 }
-230
-231 /**
-232 * convert a Base64 encoded string to a UTF-8 encoded string including CJK or Latin.<br/>
-233 * @param {String} s Base64 encoded string
-234 * @return {String} UTF-8 encoded string
-235 * @since 1.1.1
-236 */
-237 function b64toutf8(s) {
-238 return decodeURIComponent(hextouricmp(b64tohex(s)));
-239 }
-240
-241 // ==== utf8 / hex ================================
-242 /**
-243 * convert a UTF-8 encoded string including CJK or Latin to a hexadecimal encoded string.<br/>
-244 * @param {String} s UTF-8 encoded string
-245 * @return {String} hexadecimal encoded string
-246 * @since 1.1.1
-247 */
-248 function utf8tohex(s) {
-249 return uricmptohex(encodeURIComponentAll(s));
-250 }
-251
-252 /**
-253 * convert a hexadecimal encoded string to a UTF-8 encoded string including CJK or Latin.<br/>
-254 * Note that when input is improper hexadecimal string as UTF-8 string, this function returns
-255 * 'null'.
-256 * @param {String} s hexadecimal encoded string
-257 * @return {String} UTF-8 encoded string or null
-258 * @since 1.1.1
-259 */
-260 function hextoutf8(s) {
-261 return decodeURIComponent(hextouricmp(s));
-262 }
-263
-264 /**
-265 * convert a hexadecimal encoded string to raw string including non printable characters.<br/>
-266 * @param {String} s hexadecimal encoded string
-267 * @return {String} raw string
-268 * @since 1.1.2
-269 * @example
-270 * hextorstr("610061") → "a\x00a"
-271 */
-272 function hextorstr(sHex) {
-273 var s = "";
-274 for (var i = 0; i < sHex.length - 1; i += 2) {
-275 s += String.fromCharCode(parseInt(sHex.substr(i, 2), 16));
-276 }
-277 return s;
-278 }
-279
-280 /**
-281 * convert a raw string including non printable characters to hexadecimal encoded string.<br/>
-282 * @param {String} s raw string
-283 * @return {String} hexadecimal encoded string
-284 * @since 1.1.2
-285 * @example
-286 * rstrtohex("a\x00a") → "610061"
-287 */
-288 function rstrtohex(s) {
-289 var result = "";
-290 for (var i = 0; i < s.length; i++) {
-291 result += ("0" + s.charCodeAt(i).toString(16)).slice(-2);
-292 }
-293 return result;
-294 }
-295
-296 // ==== hex / b64nl =======================================
-297
-298 /*
-299 * since base64x 1.1.3
-300 */
-301 function hextob64(s) {
-302 return hex2b64(s);
-303 }
-304
-305 /*
-306 * since base64x 1.1.3
-307 */
-308 function hextob64nl(s) {
-309 var b64 = hextob64(s);
-310 var b64nl = b64.replace(/(.{64})/g, "$1\r\n");
-311 b64nl = b64nl.replace(/\r\n$/, '');
-312 return b64nl;
-313 }
-314
-315 /*
-316 * since base64x 1.1.3
-317 */
-318 function b64nltohex(s) {
-319 var b64 = s.replace(/[^0-9A-Za-z\/+=]*/g, '');
-320 var hex = b64tohex(b64);
-321 return hex;
-322 }
-323
-324 // ==== URIComponent / hex ================================
-325 /**
-326 * convert a URLComponent string such like "%67%68" to a hexadecimal string.<br/>
-327 * @param {String} s URIComponent string such like "%67%68"
-328 * @return {String} hexadecimal string
-329 * @since 1.1
-330 */
-331 function uricmptohex(s) {
-332 return s.replace(/%/g, "");
-333 }
-334
-335 /**
-336 * convert a hexadecimal string to a URLComponent string such like "%67%68".<br/>
-337 * @param {String} s hexadecimal string
-338 * @return {String} URIComponent string such like "%67%68"
-339 * @since 1.1
-340 */
-341 function hextouricmp(s) {
-342 return s.replace(/(..)/g, "%$1");
-343 }
-344
-345 // ==== URIComponent ================================
-346 /**
-347 * convert UTFa hexadecimal string to a URLComponent string such like "%67%68".<br/>
-348 * Note that these "<code>0-9A-Za-z!'()*-._~</code>" characters will not
-349 * converted to "%xx" format by builtin 'encodeURIComponent()' function.
-350 * However this 'encodeURIComponentAll()' function will convert
-351 * all of characters into "%xx" format.
-352 * @param {String} s hexadecimal string
-353 * @return {String} URIComponent string such like "%67%68"
-354 * @since 1.1
-355 */
-356 function encodeURIComponentAll(u8) {
-357 var s = encodeURIComponent(u8);
-358 var s2 = "";
-359 for (var i = 0; i < s.length; i++) {
-360 if (s[i] == "%") {
-361 s2 = s2 + s.substr(i, 3);
-362 i = i + 2;
-363 } else {
-364 s2 = s2 + "%" + stohex(s[i]);
-365 }
-366 }
-367 return s2;
-368 }
-369
-370 // ==== new lines ================================
-371 /**
-372 * convert all DOS new line("\r\n") to UNIX new line("\n") in
-373 * a String "s".
-374 * @param {String} s string
-375 * @return {String} converted string
-376 */
-377 function newline_toUnix(s) {
-378 s = s.replace(/\r\n/mg, "\n");
-379 return s;
-380 }
-381
-382 /**
-383 * convert all UNIX new line("\r\n") to DOS new line("\n") in
-384 * a String "s".
-385 * @param {String} s string
-386 * @return {String} converted string
-387 */
-388 function newline_toDos(s) {
-389 s = s.replace(/\r\n/mg, "\n");
-390 s = s.replace(/\n/mg, "\r\n");
-391 return s;
-392 }
-393