mirror of https://github.com/gchq/CyberChef.git
35 lines
807 B
JavaScript
35 lines
807 B
JavaScript
/**
|
|
* @author d98762625 [d98762625@gmail.com]
|
|
* @copyright Crown Copyright 2019
|
|
* @license Apache-2.0
|
|
*/
|
|
|
|
|
|
import DishTranslationType from "./DishTranslationType";
|
|
import Utils from "../Utils";
|
|
|
|
/**
|
|
* Translation methods for string dishes
|
|
*/
|
|
class DishString extends DishTranslationType {
|
|
|
|
/**
|
|
* convert the given value to a ByteArray
|
|
*/
|
|
static toByteArray() {
|
|
DishString.checkForValue(this.value);
|
|
this.value = this.value ? Utils.strToByteArray(this.value) : [];
|
|
}
|
|
|
|
/**
|
|
* convert the given value from a ByteArray
|
|
* @param {function} byteArrayToStr
|
|
*/
|
|
static fromByteArray(byteArrayToStr) {
|
|
DishString.checkForValue(this.value);
|
|
this.value = this.value ? byteArrayToStr(this.value) : "";
|
|
}
|
|
}
|
|
|
|
export default DishString;
|