mirror of https://github.com/dirtbags/fluffy.git
Compare commits
2 Commits
16ac8bd6ac
...
c66c6aea95
Author | SHA1 | Date |
---|---|---|
|
c66c6aea95 | |
|
fb2cc4c44d |
1
Makefile
1
Makefile
|
@ -16,6 +16,7 @@ TARGETS += hex
|
||||||
TARGETS += entropy
|
TARGETS += entropy
|
||||||
TARGETS += freq
|
TARGETS += freq
|
||||||
TARGETS += histogram
|
TARGETS += histogram
|
||||||
|
TARGETS += printy
|
||||||
|
|
||||||
SCRIPTS += octets
|
SCRIPTS += octets
|
||||||
|
|
||||||
|
|
13
README.md
13
README.md
|
@ -232,6 +232,19 @@ Displays the Shannon entropy of the input.
|
||||||
0.865857
|
0.865857
|
||||||
|
|
||||||
|
|
||||||
|
## printy: show density of printable octets
|
||||||
|
|
||||||
|
Displays the number of printable octets
|
||||||
|
divided by the total number of octets.
|
||||||
|
|
||||||
|
$ echo -n abcd | ./printy
|
||||||
|
1.000000
|
||||||
|
$ echo abcd | ./printy # Newline is not printable
|
||||||
|
0.800000
|
||||||
|
$ echo 00 41 | ./unhex | ./printy
|
||||||
|
0.500000
|
||||||
|
|
||||||
|
|
||||||
## pyesc: python escape input
|
## pyesc: python escape input
|
||||||
|
|
||||||
Escapes input octets for pasting into a python "print" statement.
|
Escapes input octets for pasting into a python "print" statement.
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
int c;
|
||||||
|
unsigned int count = 0;
|
||||||
|
unsigned int printy = 0;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
c = getchar();
|
||||||
|
if (EOF == c) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (isprint(c)) {
|
||||||
|
printy += 1;
|
||||||
|
}
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%f\n", printy/(float)count);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue