line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::SKey; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
25014
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
87
|
|
4
|
3
|
|
|
3
|
|
13
|
use Exporter; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
98
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
11
|
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION $HASH $HEX); |
|
3
|
|
|
|
|
59
|
|
|
3
|
|
|
|
|
6624
|
|
7
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
8
|
|
|
|
|
|
|
@EXPORT_OK = qw( key compute key_md4 key_md5 compute_md4 compute_md5 ); |
9
|
|
|
|
|
|
|
@EXPORT = qw( key key_md4 key_md5 ); |
10
|
|
|
|
|
|
|
$VERSION = '0.10'; |
11
|
|
|
|
|
|
|
$HASH = 'MD4'; # set default here, could be 4 or 5 |
12
|
|
|
|
|
|
|
$HEX= 0; # if true, return key as a hex digit string |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my @HEXDIGITS= qw( 0 1 2 3 4 5 6 7 8 9 A B C D E F); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @WORDS = qw( |
17
|
|
|
|
|
|
|
A ABE ACE ACT AD ADA ADD AGO AID AIM AIR ALL ALP AM AMY AN ANA AND ANN |
18
|
|
|
|
|
|
|
ANT ANY APE APS APT ARC ARE ARK ARM ART AS ASH ASK AT ATE AUG AUK AVE |
19
|
|
|
|
|
|
|
AWE AWK AWL AWN AX AYE BAD BAG BAH BAM BAN BAR BAT BAY BE BED BEE BEG |
20
|
|
|
|
|
|
|
BEN BET BEY BIB BID BIG BIN BIT BOB BOG BON BOO BOP BOW BOY BUB BUD |
21
|
|
|
|
|
|
|
BUG BUM BUN BUS BUT BUY BY BYE CAB CAL CAM CAN CAP CAR CAT CAW COD COG |
22
|
|
|
|
|
|
|
COL CON COO COP COT COW COY CRY CUB CUE CUP CUR CUT DAB DAD DAM DAN |
23
|
|
|
|
|
|
|
DAR DAY DEE DEL DEN DES DEW DID DIE DIG DIN DIP DO DOE DOG DON DOT DOW |
24
|
|
|
|
|
|
|
DRY DUB DUD DUE DUG DUN EAR EAT ED EEL EGG EGO ELI ELK ELM ELY EM END |
25
|
|
|
|
|
|
|
EST ETC EVA EVE EWE EYE FAD FAN FAR FAT FAY FED FEE FEW FIB FIG FIN |
26
|
|
|
|
|
|
|
FIR FIT FLO FLY FOE FOG FOR FRY FUM FUN FUR GAB GAD GAG GAL GAM GAP |
27
|
|
|
|
|
|
|
GAS GAY GEE GEL GEM GET GIG GIL GIN GO GOT GUM GUN GUS GUT GUY GYM GYP |
28
|
|
|
|
|
|
|
HA HAD HAL HAM HAN HAP HAS HAT HAW HAY HE HEM HEN HER HEW HEY HI HID |
29
|
|
|
|
|
|
|
HIM HIP HIS HIT HO HOB HOC HOE HOG HOP HOT HOW HUB HUE HUG HUH HUM HUT |
30
|
|
|
|
|
|
|
I ICY IDA IF IKE ILL INK INN IO ION IQ IRA IRE IRK IS IT ITS IVY JAB |
31
|
|
|
|
|
|
|
JAG JAM JAN JAR JAW JAY JET JIG JIM JO JOB JOE JOG JOT JOY JUG JUT KAY |
32
|
|
|
|
|
|
|
KEG KEN KEY KID KIM KIN KIT LA LAB LAC LAD LAG LAM LAP LAW LAY LEA LED |
33
|
|
|
|
|
|
|
LEE LEG LEN LEO LET LEW LID LIE LIN LIP LIT LO LOB LOG LOP LOS LOT LOU |
34
|
|
|
|
|
|
|
LOW LOY LUG LYE MA MAC MAD MAE MAN MAO MAP MAT MAW MAY ME MEG MEL MEN |
35
|
|
|
|
|
|
|
MET MEW MID MIN MIT MOB MOD MOE MOO MOP MOS MOT MOW MUD MUG MUM MY NAB |
36
|
|
|
|
|
|
|
NAG NAN NAP NAT NAY NE NED NEE NET NEW NIB NIL NIP NIT NO NOB NOD NON |
37
|
|
|
|
|
|
|
NOR NOT NOV NOW NU NUN NUT O OAF OAK OAR OAT ODD ODE OF OFF OFT OH OIL |
38
|
|
|
|
|
|
|
OK OLD ON ONE OR ORB ORE ORR OS OTT OUR OUT OVA OW OWE OWL OWN OX PA |
39
|
|
|
|
|
|
|
PAD PAL PAM PAN PAP PAR PAT PAW PAY PEA PEG PEN PEP PER PET PEW PHI PI |
40
|
|
|
|
|
|
|
PIE PIN PIT PLY PO POD POE POP POT POW PRO PRY PUB PUG PUN PUP PUT QUO |
41
|
|
|
|
|
|
|
RAG RAM RAN RAP RAT RAW RAY REB RED REP RET RIB RID RIG RIM RIO RIP |
42
|
|
|
|
|
|
|
ROB ROD ROE RON ROT ROW ROY RUB RUE RUG RUM RUN RYE SAC SAD SAG SAL |
43
|
|
|
|
|
|
|
SAM SAN SAP SAT SAW SAY SEA SEC SEE SEN SET SEW SHE SHY SIN SIP SIR |
44
|
|
|
|
|
|
|
SIS SIT SKI SKY SLY SO SOB SOD SON SOP SOW SOY SPA SPY SUB SUD SUE SUM |
45
|
|
|
|
|
|
|
SUN SUP TAB TAD TAG TAN TAP TAR TEA TED TEE TEN THE THY TIC TIE TIM |
46
|
|
|
|
|
|
|
TIN TIP TO TOE TOG TOM TON TOO TOP TOW TOY TRY TUB TUG TUM TUN TWO UN |
47
|
|
|
|
|
|
|
UP US USE VAN VAT VET VIE WAD WAG WAR WAS WAY WE WEB WED WEE WET WHO |
48
|
|
|
|
|
|
|
WHY WIN WIT WOK WON WOO WOW WRY WU YAM YAP YAW YE YEA YES YET YOU ABED |
49
|
|
|
|
|
|
|
ABEL ABET ABLE ABUT ACHE ACID ACME ACRE ACTA ACTS ADAM ADDS ADEN AFAR |
50
|
|
|
|
|
|
|
AFRO AGEE AHEM AHOY AIDA AIDE AIDS AIRY AJAR AKIN ALAN ALEC ALGA ALIA |
51
|
|
|
|
|
|
|
ALLY ALMA ALOE ALSO ALTO ALUM ALVA AMEN AMES AMID AMMO AMOK AMOS AMRA |
52
|
|
|
|
|
|
|
ANDY ANEW ANNA ANNE ANTE ANTI AQUA ARAB ARCH AREA ARGO ARID ARMY ARTS |
53
|
|
|
|
|
|
|
ARTY ASIA ASKS ATOM AUNT AURA AUTO AVER AVID AVIS AVON AVOW AWAY AWRY |
54
|
|
|
|
|
|
|
BABE BABY BACH BACK BADE BAIL BAIT BAKE BALD BALE BALI BALK BALL BALM |
55
|
|
|
|
|
|
|
BAND BANE BANG BANK BARB BARD BARE BARK BARN BARR BASE BASH BASK BASS |
56
|
|
|
|
|
|
|
BATE BATH BAWD BAWL BEAD BEAK BEAM BEAN BEAR BEAT BEAU BECK BEEF BEEN |
57
|
|
|
|
|
|
|
BEER BEET BELA BELL BELT BEND BENT BERG BERN BERT BESS BEST BETA BETH |
58
|
|
|
|
|
|
|
BHOY BIAS BIDE BIEN BILE BILK BILL BIND BING BIRD BITE BITS BLAB BLAT |
59
|
|
|
|
|
|
|
BLED BLEW BLOB BLOC BLOT BLOW BLUE BLUM BLUR BOAR BOAT BOCA BOCK BODE |
60
|
|
|
|
|
|
|
BODY BOGY BOHR BOIL BOLD BOLO BOLT BOMB BONA BOND BONE BONG BONN BONY |
61
|
|
|
|
|
|
|
BOOK BOOM BOON BOOT BORE BORG BORN BOSE BOSS BOTH BOUT BOWL BOYD BRAD |
62
|
|
|
|
|
|
|
BRAE BRAG BRAN BRAY BRED BREW BRIG BRIM BROW BUCK BUDD BUFF BULB BULK |
63
|
|
|
|
|
|
|
BULL BUNK BUNT BUOY BURG BURL BURN BURR BURT BURY BUSH BUSS BUST BUSY |
64
|
|
|
|
|
|
|
BYTE CADY CAFE CAGE CAIN CAKE CALF CALL CALM CAME CANE CANT CARD CARE |
65
|
|
|
|
|
|
|
CARL CARR CART CASE CASH CASK CAST CAVE CEIL CELL CENT CERN CHAD CHAR |
66
|
|
|
|
|
|
|
CHAT CHAW CHEF CHEN CHEW CHIC CHIN CHOU CHOW CHUB CHUG CHUM CITE CITY |
67
|
|
|
|
|
|
|
CLAD CLAM CLAN CLAW CLAY CLOD CLOG CLOT CLUB CLUE COAL COAT COCA COCK |
68
|
|
|
|
|
|
|
COCO CODA CODE CODY COED COIL COIN COKE COLA COLD COLT COMA COMB COME |
69
|
|
|
|
|
|
|
COOK COOL COON COOT CORD CORE CORK CORN COST COVE COWL CRAB CRAG CRAM |
70
|
|
|
|
|
|
|
CRAY CREW CRIB CROW CRUD CUBA CUBE CUFF CULL CULT CUNY CURB CURD CURE |
71
|
|
|
|
|
|
|
CURL CURT CUTS DADE DALE DAME DANA DANE DANG DANK DARE DARK DARN DART |
72
|
|
|
|
|
|
|
DASH DATA DATE DAVE DAVY DAWN DAYS DEAD DEAF DEAL DEAN DEAR DEBT DECK |
73
|
|
|
|
|
|
|
DEED DEEM DEER DEFT DEFY DELL DENT DENY DESK DIAL DICE DIED DIET DIME |
74
|
|
|
|
|
|
|
DINE DING DINT DIRE DIRT DISC DISH DISK DIVE DOCK DOES DOLE DOLL DOLT |
75
|
|
|
|
|
|
|
DOME DONE DOOM DOOR DORA DOSE DOTE DOUG DOUR DOVE DOWN DRAB DRAG DRAM |
76
|
|
|
|
|
|
|
DRAW DREW DRUB DRUG DRUM DUAL DUCK DUCT DUEL DUET DUKE DULL DUMB DUNE |
77
|
|
|
|
|
|
|
DUNK DUSK DUST DUTY EACH EARL EARN EASE EAST EASY EBEN ECHO EDDY EDEN |
78
|
|
|
|
|
|
|
EDGE EDGY EDIT EDNA EGAN ELAN ELBA ELLA ELSE EMIL EMIT EMMA ENDS ERIC |
79
|
|
|
|
|
|
|
EROS EVEN EVER EVIL EYED FACE FACT FADE FAIL FAIN FAIR FAKE FALL FAME |
80
|
|
|
|
|
|
|
FANG FARM FAST FATE FAWN FEAR FEAT FEED FEEL FEET FELL FELT FEND FERN |
81
|
|
|
|
|
|
|
FEST FEUD FIEF FIGS FILE FILL FILM FIND FINE FINK FIRE FIRM FISH FISK |
82
|
|
|
|
|
|
|
FIST FITS FIVE FLAG FLAK FLAM FLAT FLAW FLEA FLED FLEW FLIT FLOC FLOG |
83
|
|
|
|
|
|
|
FLOW FLUB FLUE FOAL FOAM FOGY FOIL FOLD FOLK FOND FONT FOOD FOOL FOOT |
84
|
|
|
|
|
|
|
FORD FORE FORK FORM FORT FOSS FOUL FOUR FOWL FRAU FRAY FRED FREE FRET |
85
|
|
|
|
|
|
|
FREY FROG FROM FUEL FULL FUME FUND FUNK FURY FUSE FUSS GAFF GAGE GAIL |
86
|
|
|
|
|
|
|
GAIN GAIT GALA GALE GALL GALT GAME GANG GARB GARY GASH GATE GAUL GAUR |
87
|
|
|
|
|
|
|
GAVE GAWK GEAR GELD GENE GENT GERM GETS GIBE GIFT GILD GILL GILT GINA |
88
|
|
|
|
|
|
|
GIRD GIRL GIST GIVE GLAD GLEE GLEN GLIB GLOB GLOM GLOW GLUE GLUM GLUT |
89
|
|
|
|
|
|
|
GOAD GOAL GOAT GOER GOES GOLD GOLF GONE GONG GOOD GOOF GORE GORY GOSH |
90
|
|
|
|
|
|
|
GOUT GOWN GRAB GRAD GRAY GREG GREW GREY GRID GRIM GRIN GRIT GROW GRUB |
91
|
|
|
|
|
|
|
GULF GULL GUNK GURU GUSH GUST GWEN GWYN HAAG HAAS HACK HAIL HAIR HALE |
92
|
|
|
|
|
|
|
HALF HALL HALO HALT HAND HANG HANK HANS HARD HARK HARM HART HASH HAST |
93
|
|
|
|
|
|
|
HATE HATH HAUL HAVE HAWK HAYS HEAD HEAL HEAR HEAT HEBE HECK HEED HEEL |
94
|
|
|
|
|
|
|
HEFT HELD HELL HELM HERB HERD HERE HERO HERS HESS HEWN HICK HIDE HIGH |
95
|
|
|
|
|
|
|
HIKE HILL HILT HIND HINT HIRE HISS HIVE HOBO HOCK HOFF HOLD HOLE HOLM |
96
|
|
|
|
|
|
|
HOLT HOME HONE HONK HOOD HOOF HOOK HOOT HORN HOSE HOST HOUR HOVE HOWE |
97
|
|
|
|
|
|
|
HOWL HOYT HUCK HUED HUFF HUGE HUGH HUGO HULK HULL HUNK HUNT HURD HURL |
98
|
|
|
|
|
|
|
HURT HUSH HYDE HYMN IBIS ICON IDEA IDLE IFFY INCA INCH INTO IONS IOTA |
99
|
|
|
|
|
|
|
IOWA IRIS IRMA IRON ISLE ITCH ITEM IVAN JACK JADE JAIL JAKE JANE JAVA |
100
|
|
|
|
|
|
|
JEAN JEFF JERK JESS JEST JIBE JILL JILT JIVE JOAN JOBS JOCK JOEL JOEY |
101
|
|
|
|
|
|
|
JOHN JOIN JOKE JOLT JOVE JUDD JUDE JUDO JUDY JUJU JUKE JULY JUNE JUNK |
102
|
|
|
|
|
|
|
JUNO JURY JUST JUTE KAHN KALE KANE KANT KARL KATE KEEL KEEN KENO KENT |
103
|
|
|
|
|
|
|
KERN KERR KEYS KICK KILL KIND KING KIRK KISS KITE KLAN KNEE KNEW KNIT |
104
|
|
|
|
|
|
|
KNOB KNOT KNOW KOCH KONG KUDO KURD KURT KYLE LACE LACK LACY LADY LAID |
105
|
|
|
|
|
|
|
LAIN LAIR LAKE LAMB LAME LAND LANE LANG LARD LARK LASS LAST LATE LAUD |
106
|
|
|
|
|
|
|
LAVA LAWN LAWS LAYS LEAD LEAF LEAK LEAN LEAR LEEK LEER LEFT LEND LENS |
107
|
|
|
|
|
|
|
LENT LEON LESK LESS LEST LETS LIAR LICE LICK LIED LIEN LIES LIEU LIFE |
108
|
|
|
|
|
|
|
LIFT LIKE LILA LILT LILY LIMA LIMB LIME LIND LINE LINK LINT LION LISA |
109
|
|
|
|
|
|
|
LIST LIVE LOAD LOAF LOAM LOAN LOCK LOFT LOGE LOIS LOLA LONE LONG LOOK |
110
|
|
|
|
|
|
|
LOON LOOT LORD LORE LOSE LOSS LOST LOUD LOVE LOWE LUCK LUCY LUGE LUKE |
111
|
|
|
|
|
|
|
LULU LUND LUNG LURA LURE LURK LUSH LUST LYLE LYNN LYON LYRA MACE MADE |
112
|
|
|
|
|
|
|
MAGI MAID MAIL MAIN MAKE MALE MALI MALL MALT MANA MANN MANY MARC MARE |
113
|
|
|
|
|
|
|
MARK MARS MART MARY MASH MASK MASS MAST MATE MATH MAUL MAYO MEAD MEAL |
114
|
|
|
|
|
|
|
MEAN MEAT MEEK MEET MELD MELT MEMO MEND MENU MERT MESH MESS MICE MIKE |
115
|
|
|
|
|
|
|
MILD MILE MILK MILL MILT MIMI MIND MINE MINI MINK MINT MIRE MISS MIST |
116
|
|
|
|
|
|
|
MITE MITT MOAN MOAT MOCK MODE MOLD MOLE MOLL MOLT MONA MONK MONT MOOD |
117
|
|
|
|
|
|
|
MOON MOOR MOOT MORE MORN MORT MOSS MOST MOTH MOVE MUCH MUCK MUDD MUFF |
118
|
|
|
|
|
|
|
MULE MULL MURK MUSH MUST MUTE MUTT MYRA MYTH NAGY NAIL NAIR NAME NARY |
119
|
|
|
|
|
|
|
NASH NAVE NAVY NEAL NEAR NEAT NECK NEED NEIL NELL NEON NERO NESS NEST |
120
|
|
|
|
|
|
|
NEWS NEWT NIBS NICE NICK NILE NINA NINE NOAH NODE NOEL NOLL NONE NOOK |
121
|
|
|
|
|
|
|
NOON NORM NOSE NOTE NOUN NOVA NUDE NULL NUMB OATH OBEY OBOE ODIN OHIO |
122
|
|
|
|
|
|
|
OILY OINT OKAY OLAF OLDY OLGA OLIN OMAN OMEN OMIT ONCE ONES ONLY ONTO |
123
|
|
|
|
|
|
|
ONUS ORAL ORGY OSLO OTIS OTTO OUCH OUST OUTS OVAL OVEN OVER OWLY OWNS |
124
|
|
|
|
|
|
|
QUAD QUIT QUOD RACE RACK RACY RAFT RAGE RAID RAIL RAIN RAKE RANK RANT |
125
|
|
|
|
|
|
|
RARE RASH RATE RAVE RAYS READ REAL REAM REAR RECK REED REEF REEK REEL |
126
|
|
|
|
|
|
|
REID REIN RENA REND RENT REST RICE RICH RICK RIDE RIFT RILL RIME RING |
127
|
|
|
|
|
|
|
RINK RISE RISK RITE ROAD ROAM ROAR ROBE ROCK RODE ROIL ROLL ROME ROOD |
128
|
|
|
|
|
|
|
ROOF ROOK ROOM ROOT ROSA ROSE ROSS ROSY ROTH ROUT ROVE ROWE ROWS RUBE |
129
|
|
|
|
|
|
|
RUBY RUDE RUDY RUIN RULE RUNG RUNS RUNT RUSE RUSH RUSK RUSS RUST RUTH |
130
|
|
|
|
|
|
|
SACK SAFE SAGE SAID SAIL SALE SALK SALT SAME SAND SANE SANG SANK SARA |
131
|
|
|
|
|
|
|
SAUL SAVE SAYS SCAN SCAR SCAT SCOT SEAL SEAM SEAR SEAT SEED SEEK SEEM |
132
|
|
|
|
|
|
|
SEEN SEES SELF SELL SEND SENT SETS SEWN SHAG SHAM SHAW SHAY SHED SHIM |
133
|
|
|
|
|
|
|
SHIN SHOD SHOE SHOT SHOW SHUN SHUT SICK SIDE SIFT SIGH SIGN SILK SILL |
134
|
|
|
|
|
|
|
SILO SILT SINE SING SINK SIRE SITE SITS SITU SKAT SKEW SKID SKIM SKIN |
135
|
|
|
|
|
|
|
SKIT SLAB SLAM SLAT SLAY SLED SLEW SLID SLIM SLIT SLOB SLOG SLOT SLOW |
136
|
|
|
|
|
|
|
SLUG SLUM SLUR SMOG SMUG SNAG SNOB SNOW SNUB SNUG SOAK SOAR SOCK SODA |
137
|
|
|
|
|
|
|
SOFA SOFT SOIL SOLD SOME SONG SOON SOOT SORE SORT SOUL SOUR SOWN STAB |
138
|
|
|
|
|
|
|
STAG STAN STAR STAY STEM STEW STIR STOW STUB STUN SUCH SUDS SUIT SULK |
139
|
|
|
|
|
|
|
SUMS SUNG SUNK SURE SURF SWAB SWAG SWAM SWAN SWAT SWAY SWIM SWUM TACK |
140
|
|
|
|
|
|
|
TACT TAIL TAKE TALE TALK TALL TANK TASK TATE TAUT TEAL TEAM TEAR TECH |
141
|
|
|
|
|
|
|
TEEM TEEN TEET TELL TEND TENT TERM TERN TESS TEST THAN THAT THEE THEM |
142
|
|
|
|
|
|
|
THEN THEY THIN THIS THUD THUG TICK TIDE TIDY TIED TIER TILE TILL TILT |
143
|
|
|
|
|
|
|
TIME TINA TINE TINT TINY TIRE TOAD TOGO TOIL TOLD TOLL TONE TONG TONY |
144
|
|
|
|
|
|
|
TOOK TOOL TOOT TORE TORN TOTE TOUR TOUT TOWN TRAG TRAM TRAY TREE TREK |
145
|
|
|
|
|
|
|
TRIG TRIM TRIO TROD TROT TROY TRUE TUBA TUBE TUCK TUFT TUNA TUNE TUNG |
146
|
|
|
|
|
|
|
TURF TURN TUSK TWIG TWIN TWIT ULAN UNIT URGE USED USER USES UTAH VAIL |
147
|
|
|
|
|
|
|
VAIN VALE VARY VASE VAST VEAL VEDA VEIL VEIN VEND VENT VERB VERY VETO |
148
|
|
|
|
|
|
|
VICE VIEW VINE VISE VOID VOLT VOTE WACK WADE WAGE WAIL WAIT WAKE WALE |
149
|
|
|
|
|
|
|
WALK WALL WALT WAND WANE WANG WANT WARD WARM WARN WART WASH WAST WATS |
150
|
|
|
|
|
|
|
WATT WAVE WAVY WAYS WEAK WEAL WEAN WEAR WEED WEEK WEIR WELD WELL WELT |
151
|
|
|
|
|
|
|
WENT WERE WERT WEST WHAM WHAT WHEE WHEN WHET WHOA WHOM WICK WIFE WILD |
152
|
|
|
|
|
|
|
WILL WIND WINE WING WINK WINO WIRE WISE WISH WITH WOLF WONT WOOD WOOL |
153
|
|
|
|
|
|
|
WORD WORE WORK WORM WORN WOVE WRIT WYNN YALE YANG YANK YARD YARN YAWL |
154
|
|
|
|
|
|
|
YAWN YEAH YEAR YELL YOGA YOKE |
155
|
|
|
|
|
|
|
); |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub compute_md4 { |
158
|
0
|
|
|
0
|
1
|
0
|
local $HASH = 'MD4'; |
159
|
0
|
|
|
|
|
0
|
&compute; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub compute_md5 { |
163
|
0
|
|
|
0
|
1
|
0
|
local $HASH = 'MD5'; |
164
|
0
|
|
|
|
|
0
|
&compute; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub compute_sha1 { |
168
|
0
|
|
|
0
|
1
|
0
|
local $HASH = 'SHA1'; |
169
|
0
|
|
|
|
|
0
|
&compute; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub compute { |
173
|
9
|
|
|
9
|
1
|
970
|
my ($n, $seed, $passwd, $cnt) = @_; |
174
|
9
|
|
100
|
|
|
42
|
$cnt ||= 1; |
175
|
|
|
|
|
|
|
|
176
|
9
|
|
|
|
|
12
|
my @out; |
177
|
9
|
50
|
|
|
|
25
|
die "'$n' not positive\n" if $n < 0; |
178
|
9
|
50
|
|
|
|
24
|
die "'count' ($cnt) greater than 'n' ($n)\n" if $cnt > $n; |
179
|
|
|
|
|
|
|
|
180
|
9
|
50
|
|
|
|
29
|
my $key = hash($seed.$passwd) or die "keycrunch error"; |
181
|
9
|
|
|
|
|
34
|
for (0..$n-$cnt) {$key = hash($key)} |
|
6411
|
|
|
|
|
10393
|
|
182
|
|
|
|
|
|
|
|
183
|
9
|
|
|
|
|
26
|
for (1..$cnt) { |
184
|
18
|
100
|
|
|
|
58
|
push @out, $HEX ? btoh($key) : btoe($key); |
185
|
18
|
|
|
|
|
36
|
$key = hash($key); |
186
|
|
|
|
|
|
|
} |
187
|
9
|
100
|
|
|
|
62
|
return wantarray ? @out : $out[0]; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub key_md4 { |
191
|
0
|
|
|
0
|
1
|
0
|
local $HASH = 'MD4'; |
192
|
0
|
|
|
|
|
0
|
&key; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub key_md5 { |
196
|
0
|
|
|
0
|
1
|
0
|
local $HASH = 'MD5'; |
197
|
0
|
|
|
|
|
0
|
&key; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub key_sha1 { |
201
|
0
|
|
|
0
|
1
|
0
|
local $HASH = 'SHA1'; |
202
|
0
|
|
|
|
|
0
|
&key; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub key { |
206
|
|
|
|
|
|
|
# Meant to be run from the command line, so it looks at @ARGV instead of @_ |
207
|
0
|
0
|
|
0
|
1
|
0
|
die "Usage: perl -mCrypt::Skey -e key []\n" unless @ARGV; |
208
|
0
|
|
|
|
|
0
|
require Term::ReadKey; |
209
|
0
|
|
|
|
|
0
|
Term::ReadKey->import('ReadMode'); |
210
|
0
|
|
|
|
|
0
|
my ($n, $seed, $cnt) = @ARGV; |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
# Could be: key / [] |
213
|
0
|
0
|
|
|
|
0
|
if ($n =~ m{(.+)/(.+)}) { ($n, $seed, $cnt) = ($1, $2, $_[1]) } |
|
0
|
|
|
|
|
0
|
|
214
|
0
|
0
|
|
|
|
0
|
$cnt = 1 unless defined $cnt; |
215
|
0
|
0
|
|
|
|
0
|
die "'$n' not positive\n" if $n < 0; |
216
|
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
0
|
warn "Reminder - Do not use this program while logged in via telnet or rlogin.\n"; |
218
|
0
|
|
|
|
|
0
|
print STDERR "Enter secret password: "; |
219
|
0
|
|
|
|
|
0
|
ReadMode('noecho'); |
220
|
0
|
|
|
|
|
0
|
chomp(my $passwd = ); |
221
|
0
|
|
|
|
|
0
|
ReadMode('normal'); |
222
|
0
|
|
|
|
|
0
|
print "\n"; |
223
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
0
|
my $i = 1; |
225
|
0
|
|
|
|
|
0
|
my $last; |
226
|
0
|
|
|
|
|
0
|
foreach my $line (compute($n, $seed, $passwd, $cnt)) { |
227
|
0
|
0
|
|
|
|
0
|
print $n-$cnt+$i++, ': ' if $cnt > 1; |
228
|
0
|
|
|
|
|
0
|
print "$line\n"; |
229
|
0
|
|
|
|
|
0
|
$last = $line; # For 'make test', a bit of a kludge |
230
|
|
|
|
|
|
|
} |
231
|
0
|
|
|
|
|
0
|
return $last; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub hash { |
235
|
6438
|
|
|
6438
|
0
|
5288
|
my $d; |
236
|
6438
|
100
|
|
|
|
12017
|
if ($HASH eq 'MD5') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
237
|
1340
|
|
|
|
|
4468
|
require Digest::MD5; |
238
|
1340
|
|
|
|
|
3723
|
$d = Digest::MD5::md5($_[0]); |
239
|
1340
|
|
|
|
|
3426
|
return substr($d,0,8) ^ substr($d,8,8); # Fold 16-byte result to 8 bytes |
240
|
|
|
|
|
|
|
} elsif ($HASH eq 'SHA1') { |
241
|
3758
|
|
|
|
|
13082
|
require Digest::SHA1; |
242
|
3758
|
|
|
|
|
18097
|
$d = Digest::SHA1::sha1($_[0]); |
243
|
|
|
|
|
|
|
# Fold 20-byte result to 8 bytes |
244
|
3758
|
|
|
|
|
6024
|
my $folded= substr($d,0,8) ^ substr($d,8,8); |
245
|
3758
|
|
|
|
|
5216
|
$folded= (substr($folded,0,4) ^ substr($d,16,4)) . substr($folded,4,4); |
246
|
|
|
|
|
|
|
# SHA1 is big-endian, but RFC2289 mandates little-endian result |
247
|
3758
|
|
|
|
|
9989
|
return pack("N2", unpack("V2", $folded)); |
248
|
|
|
|
|
|
|
} elsif ($HASH eq 'MD4') { |
249
|
1340
|
|
|
|
|
3923
|
require Digest::MD4; |
250
|
1340
|
|
|
|
|
3178
|
$d = Digest::MD4->hash($_[0]); |
251
|
1340
|
|
|
|
|
12400
|
return substr($d,0,8) ^ substr($d,8,8); # Fold 16-byte result to 8 bytes |
252
|
|
|
|
|
|
|
} else { |
253
|
0
|
|
|
|
|
0
|
die "Unrecognized algorithm: '$HASH'"; |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub checksum { |
258
|
|
|
|
|
|
|
# Gotta be a better way to do this. |
259
|
15
|
|
|
15
|
0
|
23
|
my ($data,$n) = @_; |
260
|
15
|
|
|
|
|
17
|
my $sum = 0; |
261
|
15
|
|
|
|
|
36
|
my $bin_string = unpack("B64",$data); |
262
|
|
|
|
|
|
|
|
263
|
15
|
|
|
|
|
35
|
for (0..length($bin_string)/$n-1) { |
264
|
480
|
|
|
|
|
878
|
$sum += unpack("n", pack("B16", ('0'x(16-$n)) . substr($bin_string, $_*$n, $n))); |
265
|
|
|
|
|
|
|
} |
266
|
15
|
|
|
|
|
28
|
$sum %= 2**$n; |
267
|
|
|
|
|
|
|
|
268
|
15
|
|
|
|
|
33
|
return $sum; |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub btoh { |
272
|
|
|
|
|
|
|
# Binary to hex |
273
|
3
|
|
|
3
|
0
|
9
|
my $binary = shift; |
274
|
3
|
|
|
|
|
19
|
return join '', map $HEXDIGITS[extract($binary, 4*$_, 4)], 0..15; |
275
|
|
|
|
|
|
|
} |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
sub btoe { |
278
|
|
|
|
|
|
|
# Binary to english |
279
|
15
|
|
|
15
|
0
|
51
|
my $binary = shift; |
280
|
|
|
|
|
|
|
|
281
|
15
|
|
|
|
|
26
|
my $p = checksum($binary,2); |
282
|
15
|
|
|
|
|
31
|
$binary .= chr($p << 6); |
283
|
|
|
|
|
|
|
|
284
|
15
|
|
|
|
|
72
|
return join ' ', map $WORDS[extract($binary,11*$_,11)], 0..5; |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub extract { |
288
|
|
|
|
|
|
|
# Extracts $length bits from $binary, starting at $offset, and |
289
|
|
|
|
|
|
|
# converts to an integer. |
290
|
138
|
|
|
138
|
0
|
160
|
my ($binary,$offset,$length) = @_; |
291
|
|
|
|
|
|
|
|
292
|
138
|
|
|
|
|
284
|
my $binstring = '0'x32 . substr(unpack('B*',$binary),$offset,$length); |
293
|
138
|
|
|
|
|
532
|
return unpack('N', pack('B32', substr($binstring, -32))); |
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
1; |
297
|
|
|
|
|
|
|
__END__ |