Re: [crypto] Select a file randomly
On Sat, Nov 10, 2001 at 01:57:19PM -0800, Karsten M. Self wrote:
> on Fri, Nov 09, 2001 at 03:55:37PM -0500, guillaume (triton@madchat.org) wrote:
> > Sorry for the off-topic, but I like this list ;)
> >
> > I'm planing on doing a little software, in C or
> > simply shell code to help users like me use crypto.
> >
> > Write message -> GPG crypto -> Jpeg Stegano -> Mail
> >
> > For the Jpeg stegano part, I need to select a file
> > randomly from a base of pictures.
> >
> > Is there a GNU utility that allready does that ?
>
> Fortune.
>
> Several routines in Perl are posted regularly to various lists.
I wrote a digital pictureframe-like script which uses something
like:
find $1 -iname '*jpg' | grep -v .xvpics > /tmp/imagelist
lines=`cat /tmp/imagelist | wc -l`
while [ true ]; do
wowie=$RANDOM
lines=$[$lines - 1]
echo Lines = $lines
if [ $lines = 1 ]; then
echo "time to start over"
find $1 -iname '*jpg' | grep -v .$[$wowie % $lines]xvpics > /tmp/imagelist
lines=`cat /tmp/imagelist | wc -l`
fi
ra=$[($wowie % ($lines - 1)) + 1]
echo Random = $ra
fname=`head -n $ra /tmp/imagelist | tail -n 1`
echo "Filename: $fname"
if [ -r "$fname" ]; then
echo "I can read it."
grep -v "$fname" /tmp/imagelist > /tmp/imagelist2
rm /tmp/imagelist
mv /tmp/imagelist2 /tmp/imagelist
blah blah blah...
not cryptographically secure, but maybe that doesn't matter....
--
Audin Malmin - audin@okb-1.org
Reply to: