LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   YAD (ex zenity) front-end for mcrypt and mdecrypt (https://www.linuxquestions.org/questions/linux-general-1/yad-ex-zenity-front-end-for-mcrypt-and-mdecrypt-4175571704/)

Michael Uplawski 02-08-2016 07:31 AM

YAD (ex zenity) front-end for mcrypt and mdecrypt
 
Please tell me your opinion about this script on pastebin :

http://pastebin.com/aq9FW97f

I have been considering writing more of these script front-ends for Zenity and Yad and could not decide for any real task. File-encryption finally gives me enough inspiration to try out all those nifty controls.

Runs with YAD 0.33.1 (GTK+ 3.18.6), but probably also with previous versions.

Cheerio,

Michael

Habitual 02-08-2016 09:55 AM

I was intrigued by zenity/yad in the beginning.
But for day-to-day stuff, it's not for me "for any real task".

zenity/yad is "cute" but in the end, I'd only write something for end users.

Your script comments look good and are plentiful and well-placed.

Erm...
# Remove pre-existing files if we are about to replace them anyway.

Should that happen after the encrypt?

Michael Uplawski 02-09-2016 03:55 AM

Hi.

Thank you for the comment. YAD is just there to be used or not. What I do is basically avoid the command-line for mcrypt where I sometimes forget options and have to repeat my actions.

Quote:

Originally Posted by Habitual (Post 5497048)
zenity/yad is "cute" but in the end, I'd only write something for end users.

Right. But the options, even for YAD are many and the frugal task to create a GUI around a script will be a chore, when you first have to work out all the details. As for the exercise, mcrypt asked for some digging into the syntax for YAD and I also had to make the resulting values palatable to mcrypt. This is a new way to write shell-scripts for me. I cannot say that I were shell-guru and believe that it shows anyway.

Quote:

# Remove pre-existing files if we are about to replace them anyway.
Should that happen after the encrypt?
There are two use-cases: remove the encrypted file, before writing a new one and remove the decrypted file, prior decrypting again. My impression is that both work with the current script. This way, I avoid the program asking for the user's decision.

No, but what I was really aiming for (not with YAD but) with this thread was your comments on mcrypt and the possible uses. I admit, that I could have been more specific but the question is not really clear to myself...

The information that something is wrong with mcrypt does not satisfy me and having my problems with gpg2 -c or crypting stuff with OpenSSL, mcrypt is still my utility of choice. I never understood the problem, nor if the library or only the executable program was affected. I have an encrypted partition, but admit that I have almost or actually no use for it. Moving encrypted files around is much more interesting for me than to store them for good and possibly destroy them all at once, in case of (what?) emergency...

In conclusion, if mcrypt is useable and nice, my YAD script might ... make it even better, I guess.., or something.

ntubski 02-09-2016 03:48 PM

Code:

yad --image "dialog-error" --title "ERROR" --text="$FILE is not a valid file for $ACTIONion! Aborting."
You need braces around the $ACTION variable, like this:
Code:

yad --image "dialog-error" --title "ERROR" --text="$FILE is not a valid file for ${ACTION}ion! Aborting."
Otherwise it would look for a variable called "ACTIONion".

Code:

# find the default algorithm and mark it
# with '^' for yad
AL=''
for i in `seq 0 50`
do
    if [ ${ALGOS[$i]} != ' ' ]
    then
        a=${ALGOS[$i]}
        if [ "$DEF_ALGO" == $a ]
        then
            a="^$a"
        fi
        AL="$a $AL"
    else
        break
    fi
done

I think it's equivalent to:
Code:

AL=${ALGOS[*]/$DEF_ALGO/^$DEF_ALGO}
Shell Parameter Expansion:
Quote:

${parameter/pattern/string}

The pattern is expanded to produce a pattern just as in filename expansion. Parameter is expanded and the longest match of pattern against its value is replaced with string. If pattern begins with ‘/’, all matches of pattern are replaced with string. Normally only the first match is replaced. If pattern begins with ‘#’, it must match at the beginning of the expanded value of parameter. If pattern begins with ‘%’, it must match at the end of the expanded value of parameter. If string is null, matches of pattern are deleted and the / following pattern may be omitted. If parameter is ‘@’ or ‘*’, the substitution operation is applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable subscripted with ‘@’ or ‘*’, the substitution operation is applied to each member of the array in turn, and the expansion is the resultant list.

unSpawn 02-10-2016 12:26 PM

mcrypt and mdecrypt may be related to security but your initial post is not. To make your thread get the attention it deserves I've moved it to the Linux General forum. Have fun!

Michael Uplawski 02-12-2016 06:43 AM

Quote:

Originally Posted by unSpawn (Post 5498195)
mcrypt and mdecrypt may be related to security but your initial post is not. To make your thread get the attention it deserves I've moved it to the Linux General forum. Have fun!

I am sorry for the late response, but access to the Internet is a disaster in some areas of France, in 2016.
@unSpawn: Okay, I will have to open another thread on mcrypt (alone) in the security-forum, as the question still bugs me. [Done. New thread: mcrypt, what is the problem?]

@ntubski:
Code:

AL=${ALGOS[*]/$DEF_ALGO/^$DEF_ALGO}
Looks very nice. The man page has served me often enough, but I would not have known how to look for this detail. Most “discoveries” I make by accident, or because people tell me explicitly (I have carved three notches in oak- and fir-wood today, and they fit!). ;-)


All times are GMT -5. The time now is 05:21 AM.