diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-03-12 19:10:16 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-03-12 19:10:16 +0000 |
commit | be609ff2b0ca885612c0e6d81f82c4f26ed4f58d (patch) | |
tree | b9f83fdc44bd00921ffb9c23035b1f39d565ba93 /crypting.c | |
parent | 08e5bb2bb2fcc7125f837be4f225d3a9ebf320ed (diff) | |
parent | 8b6b7405d3844271f7bff56e527bfeb1a4872975 (diff) |
Merging mainline.
Diffstat (limited to 'crypting.c')
-rw-r--r-- | crypting.c | 60 |
1 files changed, 0 insertions, 60 deletions
@@ -131,63 +131,3 @@ char *deobfucrypt (char *line, const char *password) return (rv); } - -#ifdef CRYPTING_MAIN - -/* A little main() function for people who want a stand-alone program to - encode/decode BitlCrypted files. */ - -int main( int argc, char *argv[] ) -{ - char *hash, *action, line[256]; - char* (*func)( char *, const char * ); - - if( argc < 2 ) - { - fprintf( stderr, "Usage: %s <password>\n\n" - "Reads from stdin, writes to stdout.\n" - "Call as \"encode\" to encode, \"decode\" to decode.\n", argv[0] ); - return( 1 ); - } - - hash = hashpass( argv[1] ); - action = argv[0] + strlen( argv[0] ) - strlen( "encode" ); - - if( strcmp( action, "encode" ) == 0 ) - { - fwrite( hash, 32, 1, stdout ); - func = obfucrypt; - } - else if( strcmp( action, "decode" ) == 0 ) - { - char hash2[32]; - - fread( hash2, 32, 1, stdin ); - if( memcmp( hash, hash2, 32 ) != 0 ) - { - fprintf( stderr, "Passwords don't match. Can't decode.\n" ); - return( 1 ); - } - func = deobfucrypt; - } - else - { - return( main( 0, NULL ) ); - } - - while( fscanf( stdin, "%[^\n]255s", line ) > 0 ) - { - char *out; - - /* Flush the newline */ - fgetc( stdin ); - - out = func( line, argv[1] ); - printf( "%s\n", out ); - g_free( out ); - } - - return( 0 ); -} - -#endif |