|
@@ -9,6 +9,7 @@ import moment from "moment-timezone";
|
|
import {fromBase64} from "./lib/Base64";
|
|
import {fromBase64} from "./lib/Base64";
|
|
import {fromHex} from "./lib/Hex";
|
|
import {fromHex} from "./lib/Hex";
|
|
import {fromDecimal} from "./lib/Decimal";
|
|
import {fromDecimal} from "./lib/Decimal";
|
|
|
|
+import {fromBinary} from "./lib/Binary";
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -298,7 +299,7 @@ class Utils {
|
|
* Accepts hex, Base64, UTF8 and Latin1 strings.
|
|
* Accepts hex, Base64, UTF8 and Latin1 strings.
|
|
*
|
|
*
|
|
* @param {string} str
|
|
* @param {string} str
|
|
- * @param {string} type - One of "Hex", "Decimal", "Base64", "UTF8" or "Latin1"
|
|
|
|
|
|
+ * @param {string} type - One of "Binary", "Hex", "Decimal", "Base64", "UTF8" or "Latin1"
|
|
* @returns {byteArray}
|
|
* @returns {byteArray}
|
|
*
|
|
*
|
|
* @example
|
|
* @example
|
|
@@ -313,6 +314,8 @@ class Utils {
|
|
*/
|
|
*/
|
|
static convertToByteArray(str, type) {
|
|
static convertToByteArray(str, type) {
|
|
switch (type.toLowerCase()) {
|
|
switch (type.toLowerCase()) {
|
|
|
|
+ case "binary":
|
|
|
|
+ return fromBinary(str);
|
|
case "hex":
|
|
case "hex":
|
|
return fromHex(str);
|
|
return fromHex(str);
|
|
case "decimal":
|
|
case "decimal":
|
|
@@ -333,7 +336,7 @@ class Utils {
|
|
* Accepts hex, Base64, UTF8 and Latin1 strings.
|
|
* Accepts hex, Base64, UTF8 and Latin1 strings.
|
|
*
|
|
*
|
|
* @param {string} str
|
|
* @param {string} str
|
|
- * @param {string} type - One of "Hex", "Decimal", "Base64", "UTF8" or "Latin1"
|
|
|
|
|
|
+ * @param {string} type - One of "Binary", "Hex", "Decimal", "Base64", "UTF8" or "Latin1"
|
|
* @returns {string}
|
|
* @returns {string}
|
|
*
|
|
*
|
|
* @example
|
|
* @example
|
|
@@ -348,6 +351,8 @@ class Utils {
|
|
*/
|
|
*/
|
|
static convertToByteString(str, type) {
|
|
static convertToByteString(str, type) {
|
|
switch (type.toLowerCase()) {
|
|
switch (type.toLowerCase()) {
|
|
|
|
+ case "binary":
|
|
|
|
+ return Utils.byteArrayToChars(fromBinary(str));
|
|
case "hex":
|
|
case "hex":
|
|
return Utils.byteArrayToChars(fromHex(str));
|
|
return Utils.byteArrayToChars(fromHex(str));
|
|
case "decimal":
|
|
case "decimal":
|