Class Index | File Index

Classes


Built-In Namespace global__

Method Summary
Method Attributes Method Name and Description
 
convert an ArrayBuffer to a hexadecimal string
This function converts from an ArrayBuffer to a hexadecimal string.
 
aryval(val, keys, def)
get value of array by key name list
This function returns the value of an array or associative array which referred by a concatinated key list string.
 
convert a Base64 encoded string with new lines to a hexadecimal string
This function converts from a Base64 encoded string with new lines to a hexadecimal string.
 
convert a Base64 encoded string to a Base64URL encoded string.
 
b64topem(b64, pemHeader)
get PEM string from Base64 string This function converts a Base64 string to a PEM string with a specified header.
 
convert a Base64 encoded string to a UTF-8 encoded string including CJK or Latin.
 
convert a Base64URL encoded string to a Base64 encoded string.
 
convert a Base64URL encoded string to a hexadecimal string.
 
convert a Base64URL encoded string to a ASCII string.
 
convert a Base64URL encoded string to a UTF-8 encoded string including CJK or Latin.
 
convert an array of bytes(Number) to hexadecimal string.
 
BAtos(a)
convert an array of character codes to a string
 
convert from binary string to hexadecimal string of ASN.1 BitString value with unused bit
This function converts from an binary string (ex.
 
convert from hexadecimal string of ASN.1 BitString value with unused bit to binary string
This function converts from hexadecimal string of ASN.1 BitString value with unused bit to its integer value.
 
convert from hexadecimal string of ASN.1 BitString value with unused bit to integer value
This function converts from hexadecimal string of ASN.1 BitString value with unused bit to its integer value.
 
datetozulu(d, flagUTCTime, flagMilli)
Date object to zulu time string
This function converts from Date object to GeneralizedTime string (i.e.
 
convert UTFa hexadecimal string to a URLComponent string such like "%67%68".
 
extendClass(subClass, superClass)
set class inheritance
This function extends a class and set an inheritance for member variables and methods.
 
foldnl(s, n)
wrap string with new lines to fit in specified width
This function wrap a string with new lines to fit in specified width.
 
convert a hexadecimal string to an ArrayBuffer
This function converts from a hexadecimal string to an ArrayBuffer.
 
convert a hexadecimal string to Base64 encoded string
This function converts from a hexadecimal string to Base64 encoded string without new lines.
 
convert a hexadecimal string to Base64 encoded string with new lines
This function converts from a hexadecimal string to Base64 encoded string with new lines for each 64 characters.
 
convert a hexadecimal string to a Base64URL encoded string.
 
convert a hexadecimal string to IP addresss
This function converts a hexadecimal string of IPv4 or IPv6 address to IPv4 or IPv6 address string.
 
convert a 16 byte hexadecimal string to RFC 5952 canonicalized IPv6 address
This function converts a 16 byte hexadecimal string to RFC 5952 canonicalized IPv6 address string.
 
get oid string from hexadecimal value of object identifier
This static method converts from hexadecimal object identifier value to dot noted OID value (ex.
 
hextopem(dataHex, pemHeader)
get PEM string from hexadecimal data and header string This function converts a hexadecimal string to a PEM string with a specified header.
 
canonicalize hexadecimal string of positive integer
This method canonicalize a hexadecimal string of positive integer for two's complement representation.
 
convert a hexadecimal encoded string to raw string including non printable characters.
 
convert a hexadecimal string to a URLComponent string such like "%67%68".
 
convert a hexadecimal encoded string to a UTF-8 encoded string including CJK or Latin.
 
convert string of integer array to hexadecimal string.
 
convert from integer value to hexadecimal string of ASN.1 BitString value with unused bit
This function converts from an integer value to hexadecimal string of ASN.1 BitString value with unused bit.
 
get hexadecimal string of minimum two's complement of integer
This static method converts from integer value to a minimum length hexadecimal string of two's complement of the integer.
 
convert IPv4/v6 addresss to a hexadecimal string
This function converts IPv4 or IPv6 address string to a hexadecimal string of IPv4 or IPv6 address.
 
convert any IPv6 address to a 16 byte hexadecimal string This function converts any IPv6 address representation string to a 16 byte hexadecimal string of address.
<static>  
check whether a string is a base64url encoded string and dot or not
Input string can conclude new lines or space characters.
<static>  
ishex(s)
check whether a string is an hexadecimal string or not
 
convert a hexadecimal ISO 8859-1 latin string to UTF-8 string
 
convert a hexadecimal ISO 8859-1 latin string to UTF-8 hexadecimal string
 
Unix origin milliseconds GeneralizedTime string
This function converts from milliseconds of Unix origin time (ex.
 
namearraytobinstr(namearray, namedb)
convert array of names to bit string
This function converts from an array of names to a binary string.
 
convert all UNIX new line("\r\n") to DOS new line("\n") in a String "s".
 
convert all DOS new line("\r\n") to UNIX new line("\n") in a String "s".
 
oidtohex(oidString)
get hexadecimal value of object identifier from dot noted oid value This static method converts from object identifier value string.
 
get Base64 string from PEM format data
This static method gets a Base64 string of contents from PEM format data.
 
pemtohex(s, sHead)
get hexacedimal string from PEM format data
This static method gets a hexacedimal string of contents from PEM format data.
 
printJSON(json, prefix)
output JSON object to console This method writes JSON object to console.
 
readFile(binFile)
read file and return file contents This function only works in Node.js.
 
read binary file and return file contents as hexadecimal string This function only works in Node.js.
 
readFileUTF8(utf8File)
read file and return file contents as utf-8 string This function only works in Node.js.
 
readJSON(JSON)
read JSON file and return its JSON object This function only works in Node.js.
 
readJSONC(JSONC)
read JSONC file and return its JSON object This method read JSONC (i.e.
 
convert a raw string including non printable characters to hexadecimal encoded string.
 
saveFile(binFile, rawString)
save raw string to file This function only works in Node.js.
 
saveFileBinByHex(binFile, hexString)
save data represented by hexadecimal string to file This function only works in Node.js.
 
saveFileJSON(jsonFile, json)
save JSON object as file This method saves JSON object as a file.
 
saveFileUTF8(binFile, utf8String)
save UTF-8 string to file This function only works in Node.js.
 
stob64(s)
convert a ASCII string to a Base64 encoded string.
 
convert a ASCII string to a Base64URL encoded string.
 
stoBA(s)
convert a string to an array of character codes
 
stohex(s)
convert a ASCII string to a hexadecimal string of ASCII codes.
 
strdiffidx(s1, s2)
find index of string where two string differs
 
strpad(s, len, padchar)
string padding
 
GeneralizedTime or UTCTime string to GeneralizedTime
This function converts UTCTime string (i.e.
 
get hexadecimal string of minimum two's complement of BigInteger
This static method converts from a BigInteger object to a minimum length hexadecimal string of two's complement of the integer.
 
convert UCS-2 hexadecimal stirng to UTF-8 string
This function converts hexadecimal value of UCS-2 string to UTF-8 string.
 
convert a URLComponent string such like "%67%68" to a hexadecimal string.
 
convert UTF-8 string to a hexadecimal ISO 8859-1 latin string
 
convert a UTF-8 encoded string including CJK or Latin to a Base64 encoded string.
 
convert a UTF-8 encoded string including CJK or Latin to a Base64URL encoded string.
 
convert a UTF-8 encoded string including CJK or Latin to a hexadecimal encoded string.
 
convert UTF-8 string to a hexadecimal ISO 8859-1 latin string
 
GeneralizedTime or UTCTime string to Date object
This function converts from GeneralizedTime string (i.e.
 
GeneralizedTime or UTCTime string to milliseconds from Unix origin
This function converts from GeneralizedTime string (i.e.
 
GeneralizedTime or UTCTime string to seconds from Unix origin
This function converts from GeneralizedTime string (i.e.
Method Detail
{String} ArrayBuffertohex(buffer)
convert an ArrayBuffer to a hexadecimal string
This function converts from an ArrayBuffer to a hexadecimal string.
Defined in: base64x-1.1.js.
var buffer = new ArrayBuffer(3);
var view = new DataView(buffer);
view.setUint8(0, 0xfa);
view.setUint8(1, 0xfb);
view.setUint8(2, 0x01);
ArrayBuffertohex(buffer) → "fafb01"
Parameters:
{ArrayBuffer} buffer
ArrayBuffer
Since:
jsrsasign 6.1.4 base64x 1.1.8
Returns:
{String} hexadecimal string

{object} aryval(val, keys, def)
get value of array by key name list
This function returns the value of an array or associative array which referred by a concatinated key list string. If a value for key is not defined, it returns 'undefined' by default. When an optional argument 'def' is specified and a value for key is not defined, it returns a value of 'def'.
Defined in: base64x-1.1.js.
let p = {
  fruit: apple,
  info: [
    { toy: 4 },
    { pen: 6 }
  ]
};
aryval(p, 'fruit') &rarr "apple"
aryval(p, 'info') &rarr [{toy: 4},{pen: 6}]
aryval(p, 'info.1') &rarr {pen: 6}
aryval(p, 'info.1.pen') &rarr 6
aryval(p, 'money.amount') &rarr undefined
aryval(p, 'money.amount', null) &rarr null
Parameters:
{object} val
array of associative array
{string} keys
concatinated key list with dot (ex. 'type.name.0.info')
{object} def
default value if value is not found (OPTIONAL)
Since:
jsrsasign 10.8.0 base64x 1.1.32
Returns:
{object} value if found otherwise returns def

{String} b64nltohex(s)
convert a Base64 encoded string with new lines to a hexadecimal string
This function converts from a Base64 encoded string with new lines to a hexadecimal string. This is useful to handle PEM encoded file. This function removes any non-Base64 characters (i.e. not 0-9,A-Z,a-z,\,+,=) including new line.
Defined in: base64x-1.1.js.
hextob64nl(
"MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4\r\n" +
"OTAxMjM0NTY3ODkwCg==\r\n")
→
"123456789012345678901234567890123456789012345678901234567890"
Parameters:
{String} s
Base64 encoded string with new lines
Since:
base64x 1.1.3
Returns:
{String} hexadecimal string

{String} b64tob64u(s)
convert a Base64 encoded string to a Base64URL encoded string.

Defined in: base64x-1.1.js.
b64tob64u("ab+c3f/==") → "ab-c3f_"
Parameters:
{String} s
Base64 encoded string
Returns:
{String} Base64URL encoded string

{string} b64topem(b64, pemHeader)
get PEM string from Base64 string This function converts a Base64 string to a PEM string with a specified header. Its line break will be CRLF("\r\n").
Defined in: base64x-1.1.js.
b64topem('YWFh', 'RSA PRIVATE KEY') →
-----BEGIN PRIVATE KEY-----
YWFh
-----END PRIVATE KEY-----
Parameters:
{string} b64
Base64 string of PEM body
{string} pemHeader
PEM header string (ex. 'RSA PRIVATE KEY')
Since:
jsrasign 10.7.0 base64x 1.1.31
Returns:
{string} PEM formatted string of input data

{String} b64toutf8(s)
convert a Base64 encoded string to a UTF-8 encoded string including CJK or Latin.

Defined in: base64x-1.1.js.
Parameters:
{String} s
Base64 encoded string
Since:
1.1.1
Returns:
{String} UTF-8 encoded string

{String} b64utob64(s)
convert a Base64URL encoded string to a Base64 encoded string.

Defined in: base64x-1.1.js.
b64utob64("ab-c3f_") → "ab+c3f/=="
Parameters:
{String} s
Base64URL encoded string
Returns:
{String} Base64 encoded string

{String} b64utohex(s)
convert a Base64URL encoded string to a hexadecimal string.

Defined in: base64x-1.1.js.
Parameters:
{String} s
Base64URL encoded string
Returns:
{String} hexadecimal string

{String} b64utos(s)
convert a Base64URL encoded string to a ASCII string.
NOTE: This can't be used for Base64URL encoded non ASCII characters.
Defined in: base64x-1.1.js.
Parameters:
{s} s
Base64URL encoded string
Returns:
{String} ASCII string

{String} b64utoutf8(s)
convert a Base64URL encoded string to a UTF-8 encoded string including CJK or Latin.

Defined in: base64x-1.1.js.
b64utoutf8("44GC") → "あ"
b64utoutf8("YWFh") → "aaa"
Parameters:
{String} s
Base64URL encoded string
Since:
1.1
Returns:
{String} UTF-8 encoded string

{String} BAtohex(a)
convert an array of bytes(Number) to hexadecimal string.

Defined in: base64x-1.1.js.
Parameters:
{Array of Numbers} a
array of bytes
Returns:
{String} hexadecimal string

{String} BAtos(a)
convert an array of character codes to a string
Defined in: base64x-1.1.js.
Parameters:
{Array of Numbers} a
array of character codes
Returns:
{String} s

{string} binstrtobitstr(s)
convert from binary string to hexadecimal string of ASN.1 BitString value with unused bit
This function converts from an binary string (ex. "101") to hexadecimal string of ASN.1 BitString value with unused bit (ex. "05a0").
When "s" is not binary string, this returns null.
Defined in: base64x-1.1.js.
binstrtobitstr("101") → "05a0"
binstrtobitstr("001") → "0520"
binstrtobitstr("11001") → "03c8"
binstrtobitstr("101000001") → "07a080"
binstrtobitstr(101) → null // not number
binstrtobitstr("xyz") → null // not binary string
Parameters:
{string} s
binary string (ex. "101")
Since:
jsrsasign 10.5.4 base64x 1.1.21
Returns:
{string} hexadecimal string of ASN.1 BitString value with unused bit
See:
bitstrtobinstr
inttobitstr
KJUR.asn1.DERBitString

{string} bitstrtobinstr(h)
convert from hexadecimal string of ASN.1 BitString value with unused bit to binary string
This function converts from hexadecimal string of ASN.1 BitString value with unused bit to its integer value.
When an improper hexadecimal string of BitString value is applied, this returns null.
Defined in: base64x-1.1.js.
bitstrtobinstr("05a0") → "101"
bitstrtobinstr("0520") → "001"
bitstrtobinstr("07a080") → "101000001"
bitstrtobinstr(502) → null // non ASN.1 BitString value
bitstrtobinstr("ff00") → null // for improper BitString value
Parameters:
{string} h
hexadecimal string of ASN.1 BitString value with unused bit
Since:
jsrsasign 10.5.4 base64x 1.1.21
Returns:
{string} binary string
See:
binstrtobitstr
inttobitstr

{Number} bitstrtoint(h)
convert from hexadecimal string of ASN.1 BitString value with unused bit to integer value
This function converts from hexadecimal string of ASN.1 BitString value with unused bit to its integer value.
When an improper hexadecimal string of BitString value is applied, this returns -1.
Defined in: base64x-1.1.js.
// "03c8" → 0xc8 unusedbit=03 → 11001000b unusedbit=03 → 11001b → 25
bitstrtoint("03c8") → 25
// "02fff8" → 0xfff8 unusedbit=02 → 1111111111111000b unusedbit=02
//   11111111111110b → 16382
bitstrtoint("02fff8") → 16382
bitstrtoint("05a0") → 5 (=101b)
bitstrtoint("ff00") → -1 // for improper BitString value
bitstrtoint("05a0").toString(2) → "101"
bitstrtoint("07a080").toString(2) → "101000001"
Parameters:
{String} h
hexadecimal string of ASN.1 BitString value with unused bit
Since:
jsrsasign 10.1.3 base64x 1.1.19
Returns:
{Number} positive integer value of the BitString
See:
inttobitstr
KJUR.asn1.DERBitString
ASN1HEX.getInt

{String} datetozulu(d, flagUTCTime, flagMilli)
Date object to zulu time string
This function converts from Date object to GeneralizedTime string (i.e. YYYYMMDDHHmmSSZ) or UTCTime string (i.e. YYMMDDHHmmSSZ). As for UTCTime, if year "YY" is equal or less than 49 then it is 20YY. If year "YY" is equal or greater than 50 then it is 19YY. If flagMilli is true its result concludes milliseconds such like "20170520235959.42Z".
Defined in: base64x-1.1.js.
d = new Date(Date.UTC(2017,4,20,23,59,59,670));
datetozulu(d) → "20170520235959Z"
datetozulu(d, true) → "170520235959Z"
datetozulu(d, false, true) → "20170520235959.67Z"
Parameters:
{Date} d
Date object for specified time
{Boolean} flagUTCTime
if this is true year will be YY otherwise YYYY
{Boolean} flagMilli
if this is true result concludes milliseconds
Since:
jsrsasign 7.2.0 base64x 1.1.11
Returns:
{String} GeneralizedTime or UTCTime string (ex. 20170412235959.384Z)

{String} encodeURIComponentAll(s)
convert UTFa hexadecimal string to a URLComponent string such like "%67%68".
Note that these "0-9A-Za-z!'()*-._~" characters will not converted to "%xx" format by builtin 'encodeURIComponent()' function. However this 'encodeURIComponentAll()' function will convert all of characters into "%xx" format.
Defined in: base64x-1.1.js.
Parameters:
{String} s
hexadecimal string
Since:
1.1
Returns:
{String} URIComponent string such like "%67%68"

extendClass(subClass, superClass)
set class inheritance
This function extends a class and set an inheritance for member variables and methods.
Defined in: base64x-1.1.js.
var Animal = function() {
  this.hello = function(){console.log("Hello")};
  this.name="Ani";
};
var Dog = function() {
  Dog.superclass.constructor.call(this);
  this.vow = function(){console.log("Vow wow")};
  this.tail=true;
};
extendClass(Dog, Animal);
Parameters:
{Function} subClass
sub class to set inheritance
{Function} superClass
super class to inherit
Since:
jsrsasign 10.3.0 base64x 1.1.21

{string} foldnl(s, n)
wrap string with new lines to fit in specified width
This function wrap a string with new lines to fit in specified width.
Defined in: base64x-1.1.js.
foldnl("1234567890", 6)
→
123456
7890
Parameters:
{string} s
string
{number} n
width
Since:
jsrsasign 10.7.0 base64x 1.1.31
Returns:
{string} wrapped string with new lines

{ArrayBuffer} hextoArrayBuffer(hex)
convert a hexadecimal string to an ArrayBuffer
This function converts from a hexadecimal string to an ArrayBuffer.
Defined in: base64x-1.1.js.
hextoArrayBuffer("fffa01") → ArrayBuffer of [255, 250, 1]
Parameters:
{String} hex
hexadecimal string
Since:
jsrsasign 6.1.4 base64x 1.1.8
Returns:
{ArrayBuffer} ArrayBuffer

{String} hextob64(s)
convert a hexadecimal string to Base64 encoded string
This function converts from a hexadecimal string to Base64 encoded string without new lines.
Defined in: base64x-1.1.js.
hextob64("616161") → "YWFh"
Parameters:
{String} s
hexadecimal string
Since:
base64x 1.1.3
Returns:
{String} resulted Base64 encoded string

{String} hextob64nl(s)
convert a hexadecimal string to Base64 encoded string with new lines
This function converts from a hexadecimal string to Base64 encoded string with new lines for each 64 characters. This is useful for PEM encoded file.
Defined in: base64x-1.1.js.
hextob64nl("123456789012345678901234567890123456789012345678901234567890")
→
MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4 // new line
OTAxMjM0NTY3ODkwCg==
Parameters:
{String} s
hexadecimal string
Since:
base64x 1.1.3
Returns:
{String} resulted Base64 encoded string with new lines

{String} hextob64u(s)
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.
Parameters:
{String} s
hexadecimal string
Returns:
{String} Base64URL encoded string

{String} hextoip(s)
convert a hexadecimal string to IP addresss
This function converts a hexadecimal string of IPv4 or IPv6 address to IPv4 or IPv6 address string. If byte length is not 4 nor 16, this returns a hexadecimal string without conversion.
NOTE: From jsrsasign 10.5.17, CIDR subnet mask notation also supported.
Defined in: base64x-1.1.js.
hextoip("c0a80101") → "192.168.1.1"
hextoip("871020010db8000000000000000000000004") &rarr "2001:db8::4"
hextoip("c0a80100ffffff00") → "192.168.1.0/24"
hextoip("c0a801010203") → "c0a801010203" // wrong 6 bytes
hextoip("zzz")) → raise exception because of not hexadecimal
Parameters:
{String} s
hexadecimal string of IP address
Since:
jsrsasign 8.0.10 base64x 1.1.13
Returns:
{String} IP address string
See:
hextoipv6
iptohex

{String} hextoipv6(s)
convert a 16 byte hexadecimal string to RFC 5952 canonicalized IPv6 address
This function converts a 16 byte hexadecimal string to RFC 5952 canonicalized IPv6 address string.
Defined in: base64x-1.1.js.
hextoipv6("871020010db8000000000000000000000004") &rarr "2001:db8::4"
hextoipv6("871020010db8000000000000000000") &rarr raise exception
hextoipv6("xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz") &rarr raise exception
Parameters:
{String} s
hexadecimal string of 16 byte IPv6 address
Since:
jsrsasign 8.0.10 base64x 1.1.13
Returns:
{String} IPv6 address string canonicalized by RFC 5952

{String} hextooid(h)
get oid string from hexadecimal value of object identifier
This static method converts from hexadecimal object identifier value to dot noted OID value (ex. "1.2.3.4"). oidtohex is a reverse function of this.
Defined in: base64x-1.1.js.
hextooid("550406") → "2.5.4.6"
Parameters:
{String} h
hexadecimal value of object identifier
Since:
jsrsasign 10.1.0 base64x 1.1.18
Returns:
{String} dot noted string of object identifier (ex. "1.2.3.4")
See:
oidtohex
ASN1HEX.hextooidstr
KJUR.asn1.ASN1Util.oidIntToHex

{String} hextopem(dataHex, pemHeader)
get PEM string from hexadecimal data and header string This function converts a hexadecimal string to a PEM string with a specified header. Its line break will be CRLF("\r\n").
Defined in: base64x-1.1.js.
hextopem('616161', 'RSA PRIVATE KEY') →
-----BEGIN PRIVATE KEY-----
YWFh
-----END PRIVATE KEY-----
Parameters:
{String} dataHex
hexadecimal string of PEM body
{String} pemHeader
PEM header string (ex. 'RSA PRIVATE KEY')
Since:
jsrasign 7.2.1 base64x 1.1.12
Returns:
{String} PEM formatted string of input data

{String} hextoposhex(s)
canonicalize hexadecimal string of positive integer
This method canonicalize a hexadecimal string of positive integer for two's complement representation. Canonicalized hexadecimal string of positive integer will be:
Defined in: base64x-1.1.js.
hextoposhex("abcd") → "00abcd"
hextoposhex("1234") → "1234"
hextoposhex("12345") → "012345"
Parameters:
{String} s
hexadecimal string
Since:
base64x 1.1.10 jsrsasign 7.1.4
Returns:
{String} canonicalized hexadecimal string of positive integer

{String} hextorstr(s)
convert a hexadecimal encoded string to raw string including non printable characters.

Defined in: base64x-1.1.js.
hextorstr("610061") → "a\x00a"
Parameters:
{String} s
hexadecimal encoded string
Since:
1.1.2
Returns:
{String} raw string

{String} hextouricmp(s)
convert a hexadecimal string to a URLComponent string such like "%67%68".

Defined in: base64x-1.1.js.
Parameters:
{String} s
hexadecimal string
Since:
1.1
Returns:
{String} URIComponent string such like "%67%68"

{String} hextoutf8(s)
convert a hexadecimal encoded string to a UTF-8 encoded string including CJK or Latin.
Note that when input is improper hexadecimal string as UTF-8 string, this function returns 'null'.
Defined in: base64x-1.1.js.
Parameters:
{String} s
hexadecimal encoded string
Since:
1.1.1
Returns:
{String} UTF-8 encoded string or null

{String} intarystrtohex(s)
convert string of integer array to hexadecimal string.
This function converts a string of JavaScript integer array to a hexadecimal string. Each integer value shall be in a range from 0 to 255 otherwise it raise exception. Input string can have extra space or newline string so that they will be ignored.
Defined in: base64x-1.1.js.
intarystrtohex(" [123, 34, 101, 34, 58] ")
→ 7b2265223a (i.e. '{"e":' as string)
Parameters:
{String} s
string of integer array
Since:
base64x 1.1.6 jsrsasign 5.0.2
Throws:
"malformed integer array string: *" for wrong input
Returns:
{String} hexadecimal string

{String} inttobitstr(n)
convert from integer value to hexadecimal string of ASN.1 BitString value with unused bit
This function converts from an integer value to hexadecimal string of ASN.1 BitString value with unused bit.
When "n" is not non-negative number, this returns null
Defined in: base64x-1.1.js.
// 25 → 11001b → 11001000b unusedbit=03 → 0xc8 unusedbit=03 → "03c8"
inttobitstr(25) → "03c8"
inttobitstr(-3) → null
inttobitstr("abc") → null
inttobitstr(parseInt("11001", 2)) → "03c8"
inttobitstr(parseInt("101", 2)) → "05a0"
inttobitstr(parseInt("101000001", 2)) → "07a080"
Parameters:
{Number} n
integer value of ASN.1 BitString
Since:
jsrsasign 10.1.3 base64x 1.1.19
Returns:
{String} hexadecimal string of ASN.1 BitString value with unused bit
See:
bitstrtoint
KJUR.asn1.DERBitString
ASN1HEX.getInt

{string} inttohex(i)
get hexadecimal string of minimum two's complement of integer
This static method converts from integer value to a minimum length hexadecimal string of two's complement of the integer. This method is useful for DERInteger.
Defined in: base64x-1.1.js.
inttohex(1) → "01"
inttohex(-1) → "ff"
inttohex(2048) → "0800"
inttohex(-2048) → "f800"
Parameters:
{number} i
integer value
Since:
jsrsasign 10.9.0 base64x 1.1.34
Returns:
{string} hexadecimal string of two's complement of the integer
See:
twoscompl
DERInteger

{String} iptohex(s)
convert IPv4/v6 addresss to a hexadecimal string
This function converts IPv4 or IPv6 address string to a hexadecimal string of IPv4 or IPv6 address.
NOTE: From jsrsasign 10.5.17, CIDR net mask notation also supported.
Defined in: base64x-1.1.js.
iptohex("192.168.1.1") → "c0a80101"
iptohex("2001:db8::4") → "871020010db8000000000000000000000004"
iptohex("192.168.1.1/24") → "c0a80101ffffff00"
iptohex("2001:db8::/120") → "871020010db8000000000000000000000000ffffffffffffffffffffffffffffffffff00"
iptohex("zzz")) → raise exception
Parameters:
{String} s
IPv4/v6 address string
Since:
jsrsasign 8.0.12 base64x 1.1.14
Returns:
{String} hexadecimal string of IP address
See:
hextoip
ipv6tohex

{String} ipv6tohex(s)
convert any IPv6 address to a 16 byte hexadecimal string This function converts any IPv6 address representation string to a 16 byte hexadecimal string of address.
Defined in: base64x-1.1.js.

					
					
					
						
							
Parameters:
s
string of IPv6 address
Returns:
{String} 16 byte hexadecimal string of IPv6 address

<static> {Boolean} isBase64URLDot(s)
check whether a string is a base64url encoded string and dot or not
Input string can conclude new lines or space characters.
Defined in: base64x-1.1.js.
isBase64URLDot("YWE") → true
isBase64URLDot("YWE.YWE.YWE") → true
isBase64URLDot("YW-") → true
isBase64URLDot("YW+") → false
Parameters:
{String} s
input string
Since:
base64x 1.1.30 jsrsasign 10.5.25
Returns:
{Boolean} true if a string "s" is a base64url encoded string and dot otherwise false

<static> {Boolean} ishex(s)
check whether a string is an hexadecimal string or not

Defined in: base64x-1.1.js.
ishex("1234") → true
ishex("12ab") → true
ishex("12AB") → true
ishex("12ZY") → false
ishex("121") → false -- odd length
Parameters:
{String} s
input string
Since:
base64x 1.1.7 jsrsasign 5.0.13
Returns:
{Boolean} true if a string "s" is an hexadecimal string otherwise false

{String} iso88591hextoutf8(h)
convert a hexadecimal ISO 8859-1 latin string to UTF-8 string

Defined in: base64x-1.1.js.
iso88591hextoutf8("41a9fa") → "A©ú"
Parameters:
{String} h
hexadecimal ISO 8859-1 latin string
Since:
jsrsasign 10.5.12 base64x 1.1.25
Returns:
{String} UTF-8 string
See:
utf8toiso88591hex

{String} iso88591hextoutf8hex(h)
convert a hexadecimal ISO 8859-1 latin string to UTF-8 hexadecimal string

Defined in: base64x-1.1.js.
iso88591hextoutf8hex("41a9fa") → "41c2a9c3ba"
Parameters:
{String} h
hexadecimal ISO 8859-1 latin string
Since:
jsrsasign 10.5.12 base64x 1.1.25
Returns:
{String} UTF-8 hexadecimal string
See:
iso88591hextoutf8
utf8hextoiso88591hex

{string} msectozulu(n)
Unix origin milliseconds GeneralizedTime string
This function converts from milliseconds of Unix origin time (ex. 1199145599000 for 31 Dec 2007 23:59:59 GMT) to GeneralizedTime string (i.e. YYYYMMDDHHmmSSZ). The result string may have a fraction of second.
Defined in: base64x-1.1.js.
msectozulu(1199145599000) → "20071231235959Z"       #Mon, 31 Dec 2007 23:59:59     GMT
msectozulu(1199145599100) → "20071231235959.1Z"     #Mon, 31 Dec 2007 23:59:59.1   GMT
msectozulu(1199145599123) → "20071231235959.123Z"   #Mon, 31 Dec 2007 23:59:59.123 GMT
Parameters:
{number} n
milliseconds from Unix origin time (i.e. Jan 1, 1970 0:00:00 UTC)
Since:
jsrsasign 10.8.0 base64x 1.1.31
Returns:
{string} GeneralizedTime string (ex. 20170412235959.384Z)

{string} namearraytobinstr(namearray, namedb)
convert array of names to bit string
This function converts from an array of names to a binary string. DB value bit will be set. Note that ordering of namearray items will be ignored.
Defined in: base64x-1.1.js.
db = { a: 0, b: 3, c: 8, d: 9, e: 17, f: 19 };
namearraytobinstr(['a', 'c', 'd'], db) &rarr: '1000000011'
namearraytobinstr(['c', 'b'], db) &rarr: '000100001'
Parameters:
{array} namearray
array of name string
{object} namedb
associative array of name and value
Since:
jsrsasign 10.5.21 base64x 1.1.27
Returns:
{string} binary string (ex. "110001")
See:
KJUR.asn1.x509.KeyUsage
KJUR.asn1.tsp.PKIFailureInfo

{String} newline_toDos(s)
convert all UNIX new line("\r\n") to DOS new line("\n") in a String "s".
Defined in: base64x-1.1.js.
Parameters:
{String} s
string
Returns:
{String} converted string

{String} newline_toUnix(s)
convert all DOS new line("\r\n") to UNIX new line("\n") in a String "s".
Defined in: base64x-1.1.js.
Parameters:
{String} s
string
Returns:
{String} converted string

{String} oidtohex(oidString)
get hexadecimal value of object identifier from dot noted oid value This static method converts from object identifier value string. to hexadecimal string representation of it. hextooid is a reverse function of this.
Defined in: base64x-1.1.js.
oidtohex("2.5.4.6") → "550406"
Parameters:
{String} oidString
dot noted string of object identifier
Since:
jsrsasign 10.1.0 base64x 1.1.18
Returns:
{String} hexadecimal value of object identifier
See:
hextooid
ASN1HEX.hextooidstr
KJUR.asn1.ASN1Util.oidIntToHex

{string} pemtob64(s)
get Base64 string from PEM format data
This static method gets a Base64 string of contents from PEM format data. When s is not PEM data, it returns null.
Defined in: base64x-1.1.js.
pemtohex("-----BEGIN CERTIFICATE...", "CERTIFICATE") → "MIIBvTCC..."
Parameters:
{string} s
PEM formatted string
Since:
jsrsasign 10.7.0 base64x 1.1.31
Returns:
{string} Base64 string or null

{String} pemtohex(s, sHead)
get hexacedimal string from PEM format data
This static method gets a hexacedimal string of contents from PEM format data. You can explicitly specify PEM header by sHead argument. Any space characters such as white space or new line will be omitted.
NOTE: Now KEYUTIL.getHexFromPEM and X509.pemToHex have been deprecated since jsrsasign 7.2.1.
Please use this method instead. NOTE2: From jsrsasign 8.0.14 this can process multi "BEGIN...END" section such as "EC PRIVATE KEY" with "EC PARAMETERS".

Defined in: base64x-1.1.js.
pemtohex("-----BEGIN PUBLIC KEY...") → "3082..."
pemtohex("-----BEGIN CERTIFICATE...", "CERTIFICATE") → "3082..."
pemtohex(" \r\n-----BEGIN DSA PRIVATE KEY...") → "3082..."
pemtohex("-----BEGIN EC PARAMETERS...----BEGIN EC PRIVATE KEY...." → "3082..."
Parameters:
{String} s
PEM formatted string
{String} sHead
PEM header string without BEGIN/END(OPTION)
Since:
jsrsasign 7.2.1 base64x 1.1.12
Returns:
{String} hexadecimal string data of PEM contents

printJSON(json, prefix)
output JSON object to console This method writes JSON object to console. This function only works in Node.js.
Defined in: nodeutil-1.0.js.
var rsu = require("jsrsasign-util");
var obj = {aaa: "bbb", "ccc": 123};
rsu.printJSON(obj, "obj = ") →
obj = {
  "aaa": "bbb",
  "ccc": 123
}
Parameters:
{Object} json
JSON object to print out
{Object} prefix
prefix string (OPTION)
Since:
jsrsasign-util 1.0.1 nodeutil 1.0.1

{String} readFile(binFile)
read file and return file contents This function only works in Node.js.
Defined in: nodeutil-1.0.js.
Parameters:
{String} binFile
file name to be read
Returns:
{String} raw string of file contents

{String} readFileHexByBin(binFile)
read binary file and return file contents as hexadecimal string This function only works in Node.js.
Defined in: nodeutil-1.0.js.
Parameters:
{String} binFile
file name to be read
Returns:
{String} hexadecimal string of file contents

{String} readFileUTF8(utf8File)
read file and return file contents as utf-8 string This function only works in Node.js.
Defined in: nodeutil-1.0.js.
Parameters:
{String} utf8File
file name to be read
Returns:
{String} utf-8 string of file contents

{Object} readJSON(JSON)
read JSON file and return its JSON object This function only works in Node.js.
Defined in: nodeutil-1.0.js.
var rsu = require("jsrsasign-util");
rsu.readJSON("aaa.json") → JSON object
Parameters:
{String} JSON
file name to be read
Since:
jsrsasign-util 1.0.1 nodeutil 1.0.1
Returns:
{Object} JSON object or array of file contents

{Object} readJSONC(JSONC)
read JSONC file and return its JSON object This method read JSONC (i.e. JSON with comments) file and returns JSON object. This function only works in Node.js.
Defined in: nodeutil-1.0.js.
var rsu = require("jsrsasign-util");
rsu.readJSONC("aaa.jsonc") → JSON object
Parameters:
{String} JSONC
file name to be read
Since:
jsrsasign-util 1.0.1 nodeutil 1.0.1
Returns:
{Object} JSON object or array of file contents

{String} rstrtohex(s)
convert a raw string including non printable characters to hexadecimal encoded string.

Defined in: base64x-1.1.js.
rstrtohex("a\x00a") → "610061"
Parameters:
{String} s
raw string
Since:
1.1.2
Returns:
{String} hexadecimal encoded string

saveFile(binFile, rawString)
save raw string to file This function only works in Node.js.
Defined in: nodeutil-1.0.js.
Parameters:
{String} binFile
file name to save contents.
{String} rawString
string contents to be saved.

saveFileBinByHex(binFile, hexString)
save data represented by hexadecimal string to file This function only works in Node.js.
Defined in: nodeutil-1.0.js.
Parameters:
{String} binFile
file name to save contents.
{String} hexString
hexadecimal string to be saved.

saveFileJSON(jsonFile, json)
save JSON object as file This method saves JSON object as a file. This function only works in Node.js.
Defined in: nodeutil-1.0.js.
var rsu = require("jsrsasign-util");
rsu.saveFileJSON("aaa.jsonc", json);
Parameters:
{Object} jsonFile
output JSON file name
{Object} json
JSON object to save
Since:
jsrsasign-util 1.0.1 nodeutil 1.0.1

saveFileUTF8(binFile, utf8String)
save UTF-8 string to file This function only works in Node.js.
Defined in: nodeutil-1.0.js.
Parameters:
{String} binFile
file name to save contents.
{String} utf8String
string contents to be saved.

{String} stob64(s)
convert a ASCII string to a Base64 encoded string.
NOTE: This can't be used for non ASCII characters.
Defined in: base64x-1.1.js.
Parameters:
{s} s
ASCII string
Returns:
{String} Base64 encoded string

{String} stob64u(s)
convert a ASCII string to a Base64URL encoded string.
NOTE: This can't be used for non ASCII characters.
Defined in: base64x-1.1.js.
Parameters:
{s} s
ASCII string
Returns:
{String} Base64URL encoded string

{Array of Numbers} stoBA(s)
convert a string to an array of character codes
Defined in: base64x-1.1.js.
Parameters:
{String} s
Returns:
{Array of Numbers}

{String} stohex(s)
convert a ASCII string to a hexadecimal string of ASCII codes.
NOTE: This can't be used for non ASCII characters.
Defined in: base64x-1.1.js.
Parameters:
{s} s
ASCII string
Returns:
{String} hexadecimal string

{Number} strdiffidx(s1, s2)
find index of string where two string differs
Defined in: base64x-1.1.js.
strdiffidx("abcdefg", "abcd4fg") -> 4
strdiffidx("abcdefg", "abcdefg") -> -1
strdiffidx("abcdefg", "abcdef") -> 6
strdiffidx("abcdefgh", "abcdef") -> 6
Parameters:
{String} s1
string to compare
{String} s2
string to compare
Since:
jsrsasign 4.9.0 base64x 1.1.5
Returns:
{Number} string index of where character differs. Return -1 if same.

{String} strpad(s, len, padchar)
string padding

Defined in: base64x-1.1.js.
strpad("1234", 10, "0") → "0000001234"
strpad("1234", 10, " ") → "      1234"
strpad("1234", 10)      → "0000001234"
Parameters:
{String} s
input string
{Number} len
output string length
{String} padchar
padding character (default is "0")
Since:
jsrsasign 10.1.0 base64x 1.1.18
Returns:
{String} padded string

{string} timetogen(s)
GeneralizedTime or UTCTime string to GeneralizedTime
This function converts UTCTime string (i.e. YYMMDDHHmmSSZ ) to GeneralizedTime (YYYYMMDDHHmmSSZ) when the argument 's' is UTCTime. Argument string may have fraction of seconds and its length is one or more digits such as "170410235959.1234567Z". As for UTCTime, if year "YY" is equal or less than 49 then it is 20YY. If year "YY" is equal or greater than 50 then it is 19YY.
Defined in: base64x-1.1.js.
timetogen(  "071231235959Z") → "20071231235959Z"
timetogen(  "971231235959Z") → "19971231235959Z"
timetogen("20071231235959Z") → "20071231235959Z"
timetogen(  "971231235959.123Z") → "19971231235959.123Z"
Parameters:
{string} s
GeneralizedTime or UTCTime string (ex. 20170412235959.384Z)
Since:
jsrsasign 10.7.0 base64x 1.1.31
Returns:
{string} GeneralizedTime

{string} twoscompl(bi)
get hexadecimal string of minimum two's complement of BigInteger
This static method converts from a BigInteger object to a minimum length hexadecimal string of two's complement of the integer.
NOTE: This function is a replacement of deprecated ASN1Util.bigIntToMinTwosComplementsHex method.
Defined in: base64x-1.1.js.
twoscompl(new BigInteger("1", 10)) → "01"
twoscompl(new BigInteger("-1", 10)) → "ff"
Parameters:
{BigInteger} bi
BigInteger object
Since:
jsrsasign 10.9.0 base64x 1.1.34
Returns:
{string} hexadecimal string of two's complement of the integer
See:
inttohex

{String} ucs2hextoutf8(s)
convert UCS-2 hexadecimal stirng to UTF-8 string
This function converts hexadecimal value of UCS-2 string to UTF-8 string.
Defined in: base64x-1.1.js.
ucs2hextoutf8("006600fc0072") &rarr "für"
Parameters:
{String} s
hexadecimal string of UCS-2 string (ex. "0066")
Since:
jsrsasign 10.1.13 base64x 1.1.20
Returns:
{String} UTF-8 string

{String} uricmptohex(s)
convert a URLComponent string such like "%67%68" to a hexadecimal string.

Defined in: base64x-1.1.js.
Parameters:
{String} s
URIComponent string such like "%67%68"
Since:
1.1
Returns:
{String} hexadecimal string

{String} utf8hextoiso88591hex(h)
convert UTF-8 string to a hexadecimal ISO 8859-1 latin string

Defined in: base64x-1.1.js.
utf8hextoiso88591hex("41c2a9c3ba") → "41a9fa"
Parameters:
{String} h
hexadecimal UTF-8 string
Since:
jsrsasign 10.5.12 base64x 1.1.25
Returns:
{String} hexadecimal ISO 8859-1 latin string
See:
iso88591hextoutf8hex
utf8toiso88591hex

{String} utf8tob64(s)
convert a UTF-8 encoded string including CJK or Latin to a Base64 encoded string.

Defined in: base64x-1.1.js.
Parameters:
{String} s
UTF-8 encoded string
Since:
1.1.1
Returns:
{String} Base64 encoded string

{String} utf8tob64u(s)
convert a UTF-8 encoded string including CJK or Latin to a Base64URL encoded string.

Defined in: base64x-1.1.js.
utf8tob64u("あ") → "44GC"
utf8tob64u("aaa") → "YWFh"
Parameters:
{String} s
UTF-8 encoded string
Since:
1.1
Returns:
{String} Base64URL encoded string

{String} utf8tohex(s)
convert a UTF-8 encoded string including CJK or Latin to a hexadecimal encoded string.

Defined in: base64x-1.1.js.
Parameters:
{String} s
UTF-8 encoded string
Since:
1.1.1
Returns:
{String} hexadecimal encoded string

{String} utf8toiso88591hex(s)
convert UTF-8 string to a hexadecimal ISO 8859-1 latin string

Defined in: base64x-1.1.js.
utf8toiso88591hex("A©ú") → "41a9fa"
Parameters:
{String} s
hexadecimal ISO 8859-1 latin string
Since:
jsrsasign 10.5.12 base64x 1.1.25
Returns:
{String} UTF-8 string
See:
iso88591hextoutf8

{Date} zulutodate(s)
GeneralizedTime or UTCTime string to Date object
This function converts from GeneralizedTime string (i.e. YYYYMMDDHHmmSSZ) or UTCTime string (i.e. YYMMDDHHmmSSZ) to Date object. Argument string may have fraction of seconds and its length is one or more digits such as "20170410235959.1234567Z". As for UTCTime, if year "YY" is equal or less than 49 then it is 20YY. If year "YY" is equal or greater than 50 then it is 19YY.
Defined in: base64x-1.1.js.
zulutodate(  "071231235959Z").toUTCString()   → "Mon, 31 Dec 2007 23:59:59 GMT"
zulutodate(  "071231235959.1Z").toUTCString() → "Mon, 31 Dec 2007 23:59:59 GMT"
zulutodate("20071231235959Z").toUTCString()   → "Mon, 31 Dec 2007 23:59:59 GMT"
zulutodate(  "071231235959.34").getMilliseconds() → 340
Parameters:
{String} s
GeneralizedTime or UTCTime string (ex. 20170412235959.384Z)
Since:
jsrsasign 7.1.3 base64x 1.1.9
Returns:
{Date} Date object for specified time

{Number} zulutomsec(s)
GeneralizedTime or UTCTime string to milliseconds from Unix origin
This function converts from GeneralizedTime string (i.e. YYYYMMDDHHmmSSZ) or UTCTime string (i.e. YYMMDDHHmmSSZ) to milliseconds from Unix origin time (i.e. Jan 1 1970 0:00:00 UTC). Argument string may have fraction of seconds and its length is one or more digits such as "20170410235959.1234567Z". As for UTCTime, if year "YY" is equal or less than 49 then it is 20YY. If year "YY" is equal or greater than 50 then it is 19YY.
Defined in: base64x-1.1.js.
zulutomsec(  "071231235959Z")       → 1199145599000 #Mon, 31 Dec 2007 23:59:59 GMT
zulutomsec(  "071231235959.1Z")     → 1199145599100 #Mon, 31 Dec 2007 23:59:59 GMT
zulutomsec(  "071231235959.12345Z") → 1199145599123 #Mon, 31 Dec 2007 23:59:59 GMT
zulutomsec("20071231235959Z")       → 1199145599000 #Mon, 31 Dec 2007 23:59:59 GMT
zulutomsec(  "931231235959Z")       → -410227201000 #Mon, 31 Dec 1956 23:59:59 GMT
Parameters:
{String} s
GeneralizedTime or UTCTime string (ex. 20170412235959.384Z)
Since:
jsrsasign 7.1.3 base64x 1.1.9
Returns:
{Number} milliseconds from Unix origin time (i.e. Jan 1, 1970 0:00:00 UTC)

{Number} zulutosec(s)
GeneralizedTime or UTCTime string to seconds from Unix origin
This function converts from GeneralizedTime string (i.e. YYYYMMDDHHmmSSZ) or UTCTime string (i.e. YYMMDDHHmmSSZ) to seconds from Unix origin time (i.e. Jan 1 1970 0:00:00 UTC). Argument string may have fraction of seconds however result value will be omitted. As for UTCTime, if year "YY" is equal or less than 49 then it is 20YY. If year "YY" is equal or greater than 50 then it is 19YY.
Defined in: base64x-1.1.js.
zulutosec(  "071231235959Z")       → 1199145599 #Mon, 31 Dec 2007 23:59:59 GMT
zulutosec(  "071231235959.1Z")     → 1199145599 #Mon, 31 Dec 2007 23:59:59 GMT
zulutosec("20071231235959Z")       → 1199145599 #Mon, 31 Dec 2007 23:59:59 GMT
Parameters:
{String} s
GeneralizedTime or UTCTime string (ex. 20170412235959.384Z)
Since:
jsrsasign 7.1.3 base64x 1.1.9
Returns:
{Number} seconds from Unix origin time (i.e. Jan 1, 1970 0:00:00 UTC)

© 2012-2023 Kenji Urushima, All rights reserved
Documentation generated by JsDoc Toolkit 2.4.0