Merge branch 'master' of github.com:r0ket/r0ket

This commit is contained in:
iggy 2011-08-04 22:59:09 +02:00
commit e18adf11d1
3 changed files with 130 additions and 0 deletions

58
firmware/l0dable/pwgen.c Normal file
View File

@ -0,0 +1,58 @@
#include "basic/basic.h"
#include "usetable.h"
#define PW_LEN 8
void pw_cleanup(char * pw);
void pw_set(char * pw, uint16_t * k);
void ram(void)
{
char pw[PW_LEN+1];
uint16_t k[8];
int button;
memset(k, 0, 16);
while(1){
lcdClear();
lcdNl();
lcdPrintln(" password");
lcdPrintln(" generator");
lcdNl();
lcdNl();
pw_set(pw,k);
pw_cleanup(pw);
lcdPrint(" ");
lcdPrintln(pw);
lcdRefresh();
delayms(23);
while((button=getInputRaw())==BTN_NONE)
delayms(23);
if(button==BTN_LEFT) return;
}
}
void pw_cleanup(char * pw)
{
int i;
for(i=0;i<PW_LEN;i++)
{
/* strip unwanted ascii chars */
pw[i]&=0x7f;
if(pw[i]<0x30)pw[i]+=0x30;
if(pw[i]>0x7a)pw[i]-=0x10;
if((pw[i]>'Z')&&(pw[i]<'a'))
pw[i]-=0x10;
}
}
void pw_set(char * pw, uint16_t * k)
{
int i;
memset(pw,0,PW_LEN); /* wipe old PW */
for(i=0;i<4;i++)
k[1]=getRandom();
xxtea_encode_words(pw,PW_LEN/4,k);
pw[PW_LEN]=0;
}

72
tools/image/img2lcd.pl Executable file
View File

@ -0,0 +1,72 @@
#!/usr/bin/perl
# img2lcd.pl - by <sec@42.org> 05/2011, BSD Licence
#
# This script converts an image to .lcd format for the r0ket
use strict;
use warnings;
use Getopt::Long;
use Module::Load;
$|=1;
###
### Runtime Options
###
my ($verbose);
GetOptions (
"verbose" => \$verbose, # flag
"help" => sub {
print <<HELP;
Uasge: img2lcd.pl [-v]
Options:
--verbose Be verbose.
HELP
exit(-1);}
);
###
### Code starts here.
###
my $in=shift || "i42.gif";
my $out=$in;
$out=~s/\..*/.lcd/;
load GD;
my $image = GD::Image->new($in);
my $w=$image->width;
my $h=$image->height;
my @img;
for my $y (0..$h){
for my $x (0..$w){
my $px= $image->getPixel($x,$y);
$img[$x][$y/8]|=$px<<(7-$y%8);
if($verbose){
$px=~y/01/ */; print STDERR $px;
};
};
if ($verbose){
print STDERR "<\n";
};
};
open(F,">",$out)||die "open: $!";
my $hb=int($h/8);
for my $y (0..$hb){
for my $x (0..$w){
printf F "%c",$img[$w-$x][$hb-$y];
};
};
close(F);

BIN
tools/image/src/i42.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B