mirror of
https://github.com/unraid/webgui.git
synced 2026-02-05 00:19:09 -06:00
Merge pull request #542 from bergware/master
Submit passphrases and passwords in base64 format
This commit is contained in:
@@ -75,6 +75,7 @@ tr#copy,tr#file{display:none}
|
||||
td.gap{padding-left:26px!important}
|
||||
span#pass{display:none;margin-left:20px}
|
||||
</style>
|
||||
<script src="<?autov('/webGui/javascript/jquery.base64.js')?>"></script>
|
||||
<script>
|
||||
var ctrl = "<span class='status <?=$tabbed?'':'vhshift'?>'><a style='cursor:pointer' class='tooltip_diskio' title='Toggle reads/writes display' onclick='toggle_diskio();return false'><i class='toggle fa'></i></a></span>";
|
||||
|
||||
@@ -118,39 +119,6 @@ function getFileContent(event,form) {
|
||||
reader.onload = function(){form.file.value=reader.result;selectInput(form);};
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
}
|
||||
function base64(text) {
|
||||
var xlat = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
var size = text.length;
|
||||
var tail = size % 3;
|
||||
var code = '';
|
||||
var l, t, x;
|
||||
|
||||
function encode(i) {
|
||||
return xlat.charAt(i & 0x3F);
|
||||
}
|
||||
function shift(n) {
|
||||
return encode(n >> 18) + encode(n >> 12) + encode(n >> 6) + encode(n);
|
||||
}
|
||||
for (x=0, l=size-tail; x<l; x+=3) {
|
||||
code += shift((text.charCodeAt(x) << 16) + (text.charCodeAt(x+1) << 8) + text.charCodeAt(x+2));
|
||||
}
|
||||
switch (tail) {
|
||||
case 1:
|
||||
t = text.charCodeAt(size-1);
|
||||
code += encode(t >> 2);
|
||||
code += encode(t << 4);
|
||||
code += '==';
|
||||
break;
|
||||
case 2:
|
||||
t = (text.charCodeAt(size-2) << 8) + text.charCodeAt(size-1);
|
||||
code += encode(t >> 10);
|
||||
code += encode(t >> 4);
|
||||
code += encode(t << 2);
|
||||
code += '=';
|
||||
break;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
function prepareInput(form) {
|
||||
$(form).append('<input type="hidden" name="cmdStart" value="Start">');
|
||||
if (form.input === undefined) {
|
||||
@@ -162,9 +130,8 @@ function prepareInput(form) {
|
||||
form.file.disabled = true;
|
||||
form.text.disabled = true;
|
||||
form.copy.disabled = true;
|
||||
var text = base64(form.text.value);
|
||||
if (text) {
|
||||
$(form).append('<input type="hidden" name="luksKey" value="'+text+'">');
|
||||
if (form.text.value) {
|
||||
$(form).append('<input type="hidden" name="luksKey" value="'+base64(form.text.value)+'">');
|
||||
form.submit();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ i.top{position:absolute;padding-top:4px;cursor:pointer;}
|
||||
</style>
|
||||
|
||||
<script src="<?autov('/webGui/javascript/jquery.filedrop.js')?>"></script>
|
||||
<script src="<?autov('/webGui/javascript/jquery.base64.js')?>"></script>
|
||||
<script>
|
||||
var path = '/boot/config/plugins/dynamix/users';
|
||||
var filename = '';
|
||||
@@ -61,6 +62,8 @@ function checkUsername(form) {
|
||||
if (filename) {
|
||||
$.post("/webGui/include/FileUpload.php",{cmd:'save',path:path,filename:filename,output:username+'.png'});
|
||||
}
|
||||
form.userPassword.value = base64(form.userPassword.value);
|
||||
form.userPasswordConf.value = base64(form.userPasswordConf.value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ i.top{position:absolute;padding-top:4px;cursor:pointer;}
|
||||
</style>
|
||||
|
||||
<script src="<?autov('/webGui/javascript/jquery.filedrop.js')?>"></script>
|
||||
<script src="<?autov('/webGui/javascript/jquery.base64.js')?>"></script>
|
||||
<script>
|
||||
var path = '/boot/config/plugins/dynamix/users';
|
||||
var filename = '';
|
||||
@@ -50,6 +51,8 @@ function checkPassword(form) {
|
||||
swal({title:"Password too long",text:"Use a password up to 128 characters",type:"error"});
|
||||
return false;
|
||||
}
|
||||
form.userPassword.value = base64(form.userPassword.value);
|
||||
form.userPasswordConf.value = base64(form.userPasswordConf.value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
1
plugins/dynamix/javascript/jquery.base64.js
Normal file
1
plugins/dynamix/javascript/jquery.base64.js
Normal file
@@ -0,0 +1 @@
|
||||
function base64(r){var e,t,a,c,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=r.length,n=o%3,A="";function d(r){return h.charAt(63&r)}for(a=0,e=o-n;a<e;a+=3)A+=d((c=(r.charCodeAt(a)<<16)+(r.charCodeAt(a+1)<<8)+r.charCodeAt(a+2))>>18)+d(c>>12)+d(c>>6)+d(c);switch(n){case 1:A+=d((t=r.charCodeAt(o-1))>>2),A+=d(t<<4),A+="==";break;case 2:A+=d((t=(r.charCodeAt(o-2)<<8)+r.charCodeAt(o-1))>>10),A+=d(t>>4),A+=d(t<<2),A+="="}return A}
|
||||
Reference in New Issue
Block a user