hide crypt metadata
This commit is contained in:
parent
51bd2df8d0
commit
be6618588b
|
@ -8,6 +8,14 @@ function showHideMenu()
|
|||
doc.className = "hidden-by-default";
|
||||
}
|
||||
}
|
||||
function truncateCryptFields(){
|
||||
getEncFieldsListIntegers().forEach( element=> {
|
||||
document.getElementById("form_crypt_" + element).value = "";
|
||||
});
|
||||
getEncFieldsListStrings().forEach( element=> {
|
||||
document.getElementById("form_crypt_" + element).value = "";
|
||||
});
|
||||
}
|
||||
function getEncFieldsListStrings(){
|
||||
return ['iv','mode','adata','cipher','salt'];
|
||||
}
|
||||
|
@ -29,14 +37,7 @@ function crypt()
|
|||
|
||||
document.getElementById("form_content").value = enc["ct"];
|
||||
}
|
||||
function truncateCryptFields(){
|
||||
getEncFieldsListIntegers().forEach( element=> {
|
||||
document.getElementById("form_crypt_" + element).value = "";
|
||||
});
|
||||
getEncFieldsListStrings().forEach( element=> {
|
||||
document.getElementById("form_crypt_" + element).value = "";
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function uncrypt()
|
||||
|
@ -58,6 +59,7 @@ function uncrypt()
|
|||
|
||||
|
||||
try{
|
||||
|
||||
var clearTxt = sjcl.decrypt(key,JSON.stringify(encArr));
|
||||
document.getElementById("form_content").value = clearTxt;
|
||||
truncateCryptFields();
|
||||
|
@ -67,9 +69,16 @@ function uncrypt()
|
|||
alert("Le pad n'a pas pu être déchiffré.");
|
||||
}
|
||||
}else{
|
||||
var clearTxt = sjcl.decrypt(key,document.getElementById("content").innerHTML);
|
||||
sjclArr["ct"] = document.getElementById("content").innerHTML;
|
||||
try{
|
||||
var clearTxt = sjcl.decrypt(key,JSON.stringify(sjclArr));
|
||||
document.getElementById("content").innerHTML = clearTxt;
|
||||
}
|
||||
catch(error)
|
||||
{
|
||||
alert("Le pad n'a pas pu être déchiffré.");
|
||||
}
|
||||
}
|
||||
}
|
||||
function ready(){
|
||||
document.getElementById("showOptions").addEventListener("click",showHideMenu);
|
||||
|
|
|
@ -54,12 +54,22 @@ Class PadController extends AbstractController
|
|||
|
||||
$pad = $pads[0];
|
||||
|
||||
|
||||
return $this->render('pad-view.html.twig', [
|
||||
'head_title' => 'Pad id: ' . $pad->getName(),
|
||||
'page_title' => 'Pad id: ' . $pad->getName(),
|
||||
'pad_content' => $pad->getContent(),
|
||||
'crypted' => (!empty($pad->getCryptCipher))
|
||||
'crypted' => (bool)($pad->getCryptCipher() <> "none"),
|
||||
'sjclArr' => array(
|
||||
"iv" => $pad->getCryptIv(),
|
||||
"v" => $pad->getCryptV(),
|
||||
"iter" => $pad->getCryptIter(),
|
||||
"ks" => $pad->getCryptKs(),
|
||||
"ts" => $pad->getCryptTs(),
|
||||
"mode" => $pad->getCryptMode(),
|
||||
"adata" => $pad->getCryptAdata(),
|
||||
"cipher" => $pad->getCryptCipher(),
|
||||
"salt" => $pad->getCryptSalt()
|
||||
)
|
||||
]);
|
||||
}
|
||||
private function get_free_name( $depth = 0, $length=6)
|
||||
|
@ -97,7 +107,7 @@ Class PadController extends AbstractController
|
|||
->setName( $this-> get_free_name() )
|
||||
->setCryptIv( $data["crypt_iv"] )
|
||||
->setCryptMode( $data["crypt_mode"] )
|
||||
->setCryptAdata( $data["crypt_adata"])
|
||||
->setCryptAdata( is_null( $data["crypt_adata"])? "" : $data["crypt_adata"] )
|
||||
->setCryptCipher( $data["crypt_cipher"] )
|
||||
->setCryptSalt( $data["crypt_salt"] )
|
||||
->setCryptV( $data["crypt_v"] )
|
||||
|
|
|
@ -49,7 +49,7 @@ class Pad
|
|||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $crypt_iv;
|
||||
private $crypt_iv = "";
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
|
@ -79,7 +79,7 @@ class Pad
|
|||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $crypt_cipher;
|
||||
private $crypt_cipher = "";
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
|
@ -89,7 +89,7 @@ class Pad
|
|||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $crypt_adata;
|
||||
private $crypt_adata = "";
|
||||
|
||||
|
||||
public function __construct()
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
<input type="text" id="key" placeholder="Clef de chiffrement"/>
|
||||
<input type="button" id="buttonUncrypt" value="déchiffrer"/>
|
||||
</em>
|
||||
<script>
|
||||
var sjclArr={{ sjclArr|json_encode|raw }};
|
||||
</script>
|
||||
{% endif %}
|
||||
</nav>
|
||||
<pre id="content">{{ pad_content|e('html') }}</pre>
|
||||
|
|
Loading…
Reference in New Issue
Block a user