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