Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1fe0b944f | ||
|
|
c1e40dd109 | ||
|
|
73823e3eb9 | ||
|
|
bf833991bf | ||
|
|
615357c977 | ||
|
|
19f23127b9 | ||
|
|
2ea6d9437f | ||
|
|
833b6d67a6 | ||
|
|
04c1adc5f0 | ||
|
|
8e8f6a0284 | ||
|
|
68bf1d123e | ||
|
|
2c03689195 | ||
|
|
45f41b1140 | ||
|
|
8fa6f3f45c | ||
|
|
78a842deb7 | ||
|
|
3657ff4f79 | ||
|
|
d4d12c3db0 | ||
|
|
1b628ac213 | ||
|
|
5fcc259efb | ||
|
|
9545205f19 |
@@ -22,7 +22,7 @@ deploy:
|
||||
repo: gchq/CyberChef
|
||||
branch: master
|
||||
- provider: releases
|
||||
skip_cleaup: true
|
||||
skip_cleanup: true
|
||||
api_key:
|
||||
secure: "HV1WSKv4l/0Y2bKKs1iBJocBcmLj08PCRUeEM/jTwA4jqJ8EiLHWiXtER/D5sEg2iibRVKd2OQjfrmS6bo4AiwdeVgAKmv0FtS2Jw+391N8Nd5AkEANHa5Om/IpHLTL2YRAjpJTsDpY72bMUTJIwjQA3TFJkgrpOw6KYfohOcgbxLpZ4XuNJRU3VL4Hsxdv5V9aOVmfFOmMOVPQlakXy7NgtW5POp1f2WJwgcZxylkR1CjwaqMyXmSoVl46pyH3tr5+dptsQoKSGdi6sIHGA60oDotFPcm+0ifa47wZw+vapuuDi4tdNxhrHGaDMG8xiE0WFDHwQUDlk2/+W7j9SEX0H3Em7us371JXRp56EDwEcDa34VpVkC6i8HGcHK55hnxVbMZXGf3qhOFD8wY7qMbjMRvIpucrMHBi86OfkDfv0vDj2LyvIl5APj/AX50BrE0tfH1MZbH26Jkx4NdlkcxQ14GumarmUqfmVvbX/fsoA6oUuAAE9ZgRRi3KHO4wci6KUcRfdm+XOeUkaBFsL86G3EEYIvrtBTuaypdz+Cx7nd1iPZyWMx5Y1gXnVzha4nBdV4+7l9JIsFggD8QVpw2uHXQiS1KXFjOeqA3DBD8tjMB7q26Fl2fD3jkOo4BTbQ2NrRIZUu/iL+fOmMPsyMt2qulB0yaSBCfkbEq8xrUA="
|
||||
file:
|
||||
|
||||
1736
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cyberchef",
|
||||
"version": "5.17.0",
|
||||
"version": "5.19.3",
|
||||
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
||||
"author": "n1474335 <n1474335@gmail.com>",
|
||||
"homepage": "https://gchq.github.io/CyberChef",
|
||||
@@ -82,6 +82,7 @@
|
||||
"lodash": "^4.17.4",
|
||||
"moment": "^2.17.1",
|
||||
"moment-timezone": "^0.5.11",
|
||||
"otp": "^0.1.3",
|
||||
"sladex-blowfish": "^0.8.1",
|
||||
"sortablejs": "^1.5.1",
|
||||
"split.js": "^1.2.0",
|
||||
|
||||
@@ -1235,7 +1235,8 @@ const Utils = {
|
||||
"Forward slash": /\//g,
|
||||
"Backslash": /\\/g,
|
||||
"0x": /0x/g,
|
||||
"\\x": /\\x/g
|
||||
"\\x": /\\x/g,
|
||||
"None": /\s+/g // Included here to remove whitespace when there shouldn't be any
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -122,6 +122,8 @@ const Categories = [
|
||||
"AND",
|
||||
"ADD",
|
||||
"SUB",
|
||||
"Bit shift left",
|
||||
"Bit shift right",
|
||||
"Rotate left",
|
||||
"Rotate right",
|
||||
"ROT13",
|
||||
@@ -298,6 +300,8 @@ const Categories = [
|
||||
"Detect File Type",
|
||||
"Scan for Embedded Files",
|
||||
"Generate UUID",
|
||||
"Generate TOTP",
|
||||
"Generate HOTP",
|
||||
"Render Image",
|
||||
"Remove EXIF",
|
||||
"Extract EXIF",
|
||||
|
||||
@@ -29,6 +29,7 @@ import MS from "../operations/MS.js";
|
||||
import NetBIOS from "../operations/NetBIOS.js";
|
||||
import Numberwang from "../operations/Numberwang.js";
|
||||
import OS from "../operations/OS.js";
|
||||
import OTP from "../operations/OTP.js";
|
||||
import PublicKey from "../operations/PublicKey.js";
|
||||
import Punycode from "../operations/Punycode.js";
|
||||
import QuotedPrintable from "../operations/QuotedPrintable.js";
|
||||
@@ -1595,7 +1596,7 @@ const OperationConfig = {
|
||||
args: []
|
||||
},
|
||||
"Rotate right": {
|
||||
description: "Rotates each byte to the right by the number of bits specified. Currently only supports 8-bit values.",
|
||||
description: "Rotates each byte to the right by the number of bits specified, optionally carrying the excess bits over to the next byte. Currently only supports 8-bit values.",
|
||||
run: Rotate.runRotr,
|
||||
highlight: true,
|
||||
highlightReverse: true,
|
||||
@@ -1603,19 +1604,19 @@ const OperationConfig = {
|
||||
outputType: "byteArray",
|
||||
args: [
|
||||
{
|
||||
name: "Number of bits",
|
||||
name: "Amount",
|
||||
type: "number",
|
||||
value: Rotate.ROTATE_AMOUNT
|
||||
},
|
||||
{
|
||||
name: "Rotate as a whole",
|
||||
name: "Carry through",
|
||||
type: "boolean",
|
||||
value: Rotate.ROTATE_WHOLE
|
||||
value: Rotate.ROTATE_CARRY
|
||||
}
|
||||
]
|
||||
},
|
||||
"Rotate left": {
|
||||
description: "Rotates each byte to the left by the number of bits specified. Currently only supports 8-bit values.",
|
||||
description: "Rotates each byte to the left by the number of bits specified, optionally carrying the excess bits over to the next byte. Currently only supports 8-bit values.",
|
||||
run: Rotate.runRotl,
|
||||
highlight: true,
|
||||
highlightReverse: true,
|
||||
@@ -1623,14 +1624,14 @@ const OperationConfig = {
|
||||
outputType: "byteArray",
|
||||
args: [
|
||||
{
|
||||
name: "Number of bits",
|
||||
name: "Amount",
|
||||
type: "number",
|
||||
value: Rotate.ROTATE_AMOUNT
|
||||
},
|
||||
{
|
||||
name: "Rotate as a whole",
|
||||
name: "Carry through",
|
||||
type: "boolean",
|
||||
value: Rotate.ROTATE_WHOLE
|
||||
value: Rotate.ROTATE_CARRY
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2139,7 +2140,7 @@ const OperationConfig = {
|
||||
]
|
||||
},
|
||||
"Extract domains": {
|
||||
description: "Extracts domain names with common Top-Level Domains (TLDs).<br>Note that this will not include paths. Use <strong>Extract URLs</strong> to find entire URLs.",
|
||||
description: "Extracts domain names.<br>Note that this will not include paths. Use <strong>Extract URLs</strong> to find entire URLs.",
|
||||
run: Extract.runDomains,
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
@@ -3600,6 +3601,102 @@ const OperationConfig = {
|
||||
]
|
||||
|
||||
},
|
||||
"Bit shift left": {
|
||||
description: "Shifts the bits in each byte towards the left by the specified amount.",
|
||||
run: BitwiseOp.runBitShiftLeft,
|
||||
inputType: "byteArray",
|
||||
outputType: "byteArray",
|
||||
highlight: true,
|
||||
highlightReverse: true,
|
||||
args: [
|
||||
{
|
||||
name: "Amount",
|
||||
type: "number",
|
||||
value: 1
|
||||
},
|
||||
]
|
||||
},
|
||||
"Bit shift right": {
|
||||
description: "Shifts the bits in each byte towards the right by the specified amount.<br><br><i>Logical shifts</i> replace the leftmost bits with zeros.<br><i>Arithmetic shifts</i> preserve the most significant bit (MSB) of the original byte keeping the sign the same (positive or negative).",
|
||||
run: BitwiseOp.runBitShiftRight,
|
||||
inputType: "byteArray",
|
||||
outputType: "byteArray",
|
||||
highlight: true,
|
||||
highlightReverse: true,
|
||||
args: [
|
||||
{
|
||||
name: "Amount",
|
||||
type: "number",
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
name: "Type",
|
||||
type: "option",
|
||||
value: BitwiseOp.BIT_SHIFT_TYPE
|
||||
}
|
||||
]
|
||||
},
|
||||
"Generate TOTP": {
|
||||
description: "The Time-based One-Time Password algorithm (TOTP) is an algorithm that computes a one-time password from a shared secret key and the current time. It has been adopted as Internet Engineering Task Force standard RFC 6238, is the cornerstone of Initiative For Open Authentication (OATH), and is used in a number of two-factor authentication systems. A TOTP is an HOTP where the counter is the current time.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated. T0 and T1 are in seconds.",
|
||||
run: OTP.runTOTP,
|
||||
inputType: "byteArray",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Name",
|
||||
type: "string",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Key size",
|
||||
type: "number",
|
||||
value: 32
|
||||
},
|
||||
{
|
||||
name: "Code length",
|
||||
type: "number",
|
||||
value: 6
|
||||
},
|
||||
{
|
||||
name: "Epoch offset (T0)",
|
||||
type: "number",
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
name: "Interval (T1)",
|
||||
type: "number",
|
||||
value: 30
|
||||
}
|
||||
]
|
||||
},
|
||||
"Generate HOTP": {
|
||||
description: "The HMAC-based One-Time Password algorithm (HOTP) is an algorithm that computes a one-time password from a shared secret key and an incrementing counter. It has been adopted as Internet Engineering Task Force standard RFC 4226, is the cornerstone of Initiative For Open Authentication (OATH), and is used in a number of two-factor authentication systems.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated.",
|
||||
run: OTP.runHOTP,
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Name",
|
||||
type: "string",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Key size",
|
||||
type: "number",
|
||||
value: 32
|
||||
},
|
||||
{
|
||||
name: "Code length",
|
||||
type: "number",
|
||||
value: 6
|
||||
},
|
||||
{
|
||||
name: "Counter",
|
||||
type: "number",
|
||||
value: 0
|
||||
}
|
||||
]
|
||||
},
|
||||
};
|
||||
|
||||
export default OperationConfig;
|
||||
|
||||
@@ -228,6 +228,46 @@ const BitwiseOp = {
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Bit shift left operation.
|
||||
*
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byteArray}
|
||||
*/
|
||||
runBitShiftLeft: function(input, args) {
|
||||
const amount = args[0];
|
||||
|
||||
return input.map(b => {
|
||||
return (b << amount) & 0xff;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
BIT_SHIFT_TYPE: ["Logical shift", "Arithmetic shift"],
|
||||
|
||||
/**
|
||||
* Bit shift right operation.
|
||||
*
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byteArray}
|
||||
*/
|
||||
runBitShiftRight: function(input, args) {
|
||||
const amount = args[0],
|
||||
type = args[1],
|
||||
mask = type === "Logical shift" ? 0 : 0x80;
|
||||
|
||||
return input.map(b => {
|
||||
return (b >>> amount) ^ (b & mask);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* XOR bitwise calculation.
|
||||
*
|
||||
|
||||
@@ -196,7 +196,7 @@ const ByteRepr = {
|
||||
|
||||
|
||||
/**
|
||||
* Highlight to hex
|
||||
* Highlight from hex
|
||||
*
|
||||
* @param {Object[]} pos
|
||||
* @param {number} pos[].start
|
||||
@@ -288,10 +288,8 @@ const ByteRepr = {
|
||||
* @returns {byteArray}
|
||||
*/
|
||||
runFromBinary: function(input, args) {
|
||||
if (args[0] !== "None") {
|
||||
const delimRegex = Utils.regexRep[args[0] || "Space"];
|
||||
input = input.replace(delimRegex, "");
|
||||
}
|
||||
const delimRegex = Utils.regexRep[args[0] || "Space"];
|
||||
input = input.replace(delimRegex, "");
|
||||
|
||||
const output = [];
|
||||
const byteLen = 8;
|
||||
|
||||
@@ -187,11 +187,8 @@ const Extract = {
|
||||
* @returns {string}
|
||||
*/
|
||||
runDomains: function(input, args) {
|
||||
let displayTotal = args[0],
|
||||
protocol = "https?://",
|
||||
hostname = "[-\\w\\.]+",
|
||||
tld = "\\.(?:com|net|org|biz|info|co|uk|onion|int|mobi|name|edu|gov|mil|eu|ac|ae|af|de|ca|ch|cn|cy|es|gb|hk|il|in|io|tv|me|nl|no|nz|ro|ru|tr|us|az|ir|kz|uz|pk)+",
|
||||
regex = new RegExp("(?:" + protocol + ")?" + hostname + tld, "ig");
|
||||
const displayTotal = args[0],
|
||||
regex = /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/ig;
|
||||
|
||||
return Extract._search(input, regex, null, displayTotal);
|
||||
},
|
||||
|
||||
55
src/core/operations/OTP.js
Executable file
@@ -0,0 +1,55 @@
|
||||
import otp from "otp";
|
||||
import Base64 from "./Base64.js";
|
||||
|
||||
/**
|
||||
* One-Time Password operations.
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2017
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* @namespace
|
||||
*/
|
||||
const OTP = {
|
||||
|
||||
/**
|
||||
* Generate TOTP operation.
|
||||
*
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
runTOTP: function(input, args) {
|
||||
const otpObj = otp({
|
||||
name: args[0],
|
||||
keySize: args[1],
|
||||
codeLength: args[2],
|
||||
secret: Base64.runTo32(input, []),
|
||||
epoch: args[3],
|
||||
timeSlice: args[4]
|
||||
});
|
||||
return `URI: ${otpObj.totpURL}\n\nPassword: ${otpObj.totp()}`;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Generate HOTP operation.
|
||||
*
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
runHOTP: function(input, args) {
|
||||
const otpObj = otp({
|
||||
name: args[0],
|
||||
keySize: args[1],
|
||||
codeLength: args[2],
|
||||
secret: Base64.runTo32(input, []),
|
||||
});
|
||||
const counter = args[3];
|
||||
return `URI: ${otpObj.hotpURL}\n\nPassword: ${otpObj.hotp(counter)}`;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
export default OTP;
|
||||
@@ -20,7 +20,7 @@ const Rotate = {
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
ROTATE_WHOLE: false,
|
||||
ROTATE_CARRY: false,
|
||||
|
||||
/**
|
||||
* Runs rotation operations across the input data.
|
||||
@@ -53,7 +53,7 @@ const Rotate = {
|
||||
*/
|
||||
runRotr: function(input, args) {
|
||||
if (args[1]) {
|
||||
return Rotate._rotrWhole(input, args[0]);
|
||||
return Rotate._rotrCarry(input, args[0]);
|
||||
} else {
|
||||
return Rotate._rot(input, args[0], Rotate._rotr);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ const Rotate = {
|
||||
*/
|
||||
runRotl: function(input, args) {
|
||||
if (args[1]) {
|
||||
return Rotate._rotlWhole(input, args[0]);
|
||||
return Rotate._rotlCarry(input, args[0]);
|
||||
} else {
|
||||
return Rotate._rot(input, args[0], Rotate._rotl);
|
||||
}
|
||||
@@ -197,7 +197,7 @@ const Rotate = {
|
||||
* @param {number} amount
|
||||
* @returns {byteArray}
|
||||
*/
|
||||
_rotrWhole: function(data, amount) {
|
||||
_rotrCarry: function(data, amount) {
|
||||
let carryBits = 0,
|
||||
newByte,
|
||||
result = [];
|
||||
@@ -223,7 +223,7 @@ const Rotate = {
|
||||
* @param {number} amount
|
||||
* @returns {byteArray}
|
||||
*/
|
||||
_rotlWhole: function(data, amount) {
|
||||
_rotlCarry: function(data, amount) {
|
||||
let carryBits = 0,
|
||||
newByte,
|
||||
result = [];
|
||||
|
||||
@@ -40,7 +40,7 @@ const StrUtils = {
|
||||
},
|
||||
{
|
||||
name: "Domain",
|
||||
value: "(?:(https?):\\/\\/)?([-\\w.]+)\\.(com|net|org|biz|info|co|uk|onion|int|mobi|name|edu|gov|mil|eu|ac|ae|af|de|ca|ch|cn|cy|es|gb|hk|il|in|io|tv|me|nl|no|nz|ro|ru|tr|us|az|ir|kz|uz|pk)+"
|
||||
value: "\\b((?=[a-z0-9-]{1,63}\\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,63}\\b"
|
||||
},
|
||||
{
|
||||
name: "Windows file path",
|
||||
|
||||
@@ -118,6 +118,7 @@ Manager.prototype.initialiseEventListeners = function() {
|
||||
// Recipe
|
||||
this.addDynamicListener(".arg", "keyup", this.recipe.ingChange, this.recipe);
|
||||
this.addDynamicListener(".arg", "change", this.recipe.ingChange, this.recipe);
|
||||
this.addDynamicListener(".arg", "input", this.recipe.ingChange, this.recipe);
|
||||
this.addDynamicListener(".disable-icon", "click", this.recipe.disableClick, this.recipe);
|
||||
this.addDynamicListener(".breakpoint", "click", this.recipe.breakpointClick, this.recipe);
|
||||
this.addDynamicListener("#rec-list li.operation", "dblclick", this.recipe.operationDblclick, this.recipe);
|
||||
|
||||
|
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 773 B After Width: | Height: | Size: 672 B |
|
Before Width: | Height: | Size: 702 B After Width: | Height: | Size: 654 B |
|
Before Width: | Height: | Size: 796 B After Width: | Height: | Size: 762 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 419 B After Width: | Height: | Size: 245 B |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 746 B After Width: | Height: | Size: 426 B |
|
Before Width: | Height: | Size: 590 B After Width: | Height: | Size: 467 B |
|
Before Width: | Height: | Size: 905 B After Width: | Height: | Size: 764 B |
|
Before Width: | Height: | Size: 680 B After Width: | Height: | Size: 584 B |
|
Before Width: | Height: | Size: 491 B After Width: | Height: | Size: 351 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 843 B After Width: | Height: | Size: 764 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 513 B After Width: | Height: | Size: 385 B |
|
Before Width: | Height: | Size: 334 B After Width: | Height: | Size: 320 B |
|
Before Width: | Height: | Size: 463 B After Width: | Height: | Size: 346 B |
|
Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 175 B |
|
Before Width: | Height: | Size: 474 B After Width: | Height: | Size: 446 B |
|
Before Width: | Height: | Size: 719 B After Width: | Height: | Size: 660 B |
|
Before Width: | Height: | Size: 585 B After Width: | Height: | Size: 564 B |
|
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 382 B |
|
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 179 B |
|
Before Width: | Height: | Size: 472 B After Width: | Height: | Size: 463 B |
|
Before Width: | Height: | Size: 695 B After Width: | Height: | Size: 680 B |
|
Before Width: | Height: | Size: 642 B After Width: | Height: | Size: 542 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 798 B |
|
Before Width: | Height: | Size: 360 B After Width: | Height: | Size: 345 B |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 513 B |
|
Before Width: | Height: | Size: 575 B After Width: | Height: | Size: 534 B |
|
Before Width: | Height: | Size: 472 B After Width: | Height: | Size: 336 B |
|
Before Width: | Height: | Size: 769 B After Width: | Height: | Size: 662 B |
|
Before Width: | Height: | Size: 717 B After Width: | Height: | Size: 627 B |
|
Before Width: | Height: | Size: 553 B After Width: | Height: | Size: 445 B |
@@ -13,6 +13,7 @@ import "babel-polyfill";
|
||||
import TestRegister from "./TestRegister.js";
|
||||
import "./tests/operations/Base58.js";
|
||||
import "./tests/operations/BCD.js";
|
||||
import "./tests/operations/BitwiseOp.js";
|
||||
import "./tests/operations/ByteRepr.js";
|
||||
import "./tests/operations/CharEnc.js";
|
||||
import "./tests/operations/Cipher.js";
|
||||
|
||||
50
test/tests/operations/BitwiseOp.js
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* BitwiseOp tests
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2017
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../TestRegister.js";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Bit shift left",
|
||||
input: "01010101 10101010 11111111 00000000 11110000 00001111 00110011 11001100",
|
||||
expectedOutput: "10101010 01010100 11111110 00000000 11100000 00011110 01100110 10011000",
|
||||
recipeConfig: [
|
||||
{ "op": "From Binary",
|
||||
"args": ["Space"] },
|
||||
{ "op": "Bit shift left",
|
||||
"args": [1] },
|
||||
{ "op": "To Binary",
|
||||
"args": ["Space"] }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Bit shift right: Logical shift",
|
||||
input: "01010101 10101010 11111111 00000000 11110000 00001111 00110011 11001100",
|
||||
expectedOutput: "00101010 01010101 01111111 00000000 01111000 00000111 00011001 01100110",
|
||||
recipeConfig: [
|
||||
{ "op": "From Binary",
|
||||
"args": ["Space"] },
|
||||
{ "op": "Bit shift right",
|
||||
"args": [1, "Logical shift"] },
|
||||
{ "op": "To Binary",
|
||||
"args": ["Space"] }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Bit shift right: Arithmetic shift",
|
||||
input: "01010101 10101010 11111111 00000000 11110000 00001111 00110011 11001100",
|
||||
expectedOutput: "00101010 11010101 11111111 00000000 11111000 00000111 00011001 11100110",
|
||||
recipeConfig: [
|
||||
{ "op": "From Binary",
|
||||
"args": ["Space"] },
|
||||
{ "op": "Bit shift right",
|
||||
"args": [1, "Arithmetic shift"] },
|
||||
{ "op": "To Binary",
|
||||
"args": ["Space"] }
|
||||
]
|
||||
},
|
||||
]);
|
||||