mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-25 09:16:17 -04:00
Add fernet encryption/decryption operation
This commit is contained in:
parent
8148c1a8a8
commit
846e84d3a4
6 changed files with 292 additions and 70 deletions
80
tests/operations/tests/Fernet.mjs
Normal file
80
tests/operations/tests/Fernet.mjs
Normal file
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* Fernet tests.
|
||||
*
|
||||
* @author Karsten Silkenbäumer [kassi@users.noreply.github.com]
|
||||
* @copyright Karsten Silkenbäumer 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../TestRegister";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Fernet Decrypt: no input",
|
||||
input: "",
|
||||
expectedOutput: "Error: Invalid version",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fernet Decrypt",
|
||||
args: ["MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fernet Decrypt: no secret",
|
||||
input: "gAAAAABce-Tycae8klRxhDX2uenJ-uwV8-A1XZ2HRnfOXlNzkKKfRxviNLlgtemhT_fd1Fw5P_zFUAjd69zaJBQyWppAxVV00SExe77ql8c5n62HYJOnoIU=",
|
||||
expectedOutput: "Error: Secret must be 32 url-safe base64-encoded bytes.",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fernet Decrypt",
|
||||
args: [""]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fernet Decrypt: valid arguments",
|
||||
input: "gAAAAABce-Tycae8klRxhDX2uenJ-uwV8-A1XZ2HRnfOXlNzkKKfRxviNLlgtemhT_fd1Fw5P_zFUAjd69zaJBQyWppAxVV00SExe77ql8c5n62HYJOnoIU=",
|
||||
expectedOutput: "This is a secret message.\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fernet Decrypt",
|
||||
args: ["VGhpc0lzVGhpcnR5VHdvQ2hhcmFjdGVyc0xvbmdLZXk="]
|
||||
}
|
||||
],
|
||||
}
|
||||
]);
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Fernet Encrypt: no input",
|
||||
input: "",
|
||||
expectedMatch: /^gAAAAABce-[\w-]+={0,2}$/,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fernet Encrypt",
|
||||
args: ["MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fernet Encrypt: no secret",
|
||||
input: "This is a secret message.\n",
|
||||
expectedOutput: "Error: Secret must be 32 url-safe base64-encoded bytes.",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fernet Encrypt",
|
||||
args: [""]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fernet Encrypt: valid arguments",
|
||||
input: "This is a secret message.\n",
|
||||
expectedMatch: /^gAAAAABce-[\w-]+={0,2}$/,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fernet Encrypt",
|
||||
args: ["MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="]
|
||||
}
|
||||
],
|
||||
}
|
||||
]);
|
Loading…
Add table
Add a link
Reference in a new issue