Changes in crypting.c [7c9db24:69ac78c]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
crypting.c
r7c9db24 r69ac78c 132 132 return (rv); 133 133 } 134 135 #ifdef CRYPTING_MAIN 136 137 /* A little main() function for people who want a stand-alone program to 138 encode/decode BitlCrypted files. */ 139 140 int main( int argc, char *argv[] ) 141 { 142 char *hash, *action, line[256]; 143 char* (*func)( char *, const char * ); 144 145 if( argc < 2 ) 146 { 147 fprintf( stderr, "Usage: %s <password>\n\n" 148 "Reads from stdin, writes to stdout.\n" 149 "Call as \"encode\" to encode, \"decode\" to decode.\n", argv[0] ); 150 return( 1 ); 151 } 152 153 hash = hashpass( argv[1] ); 154 action = argv[0] + strlen( argv[0] ) - strlen( "encode" ); 155 156 if( strcmp( action, "encode" ) == 0 ) 157 { 158 fwrite( hash, 32, 1, stdout ); 159 func = obfucrypt; 160 } 161 else if( strcmp( action, "decode" ) == 0 ) 162 { 163 char hash2[32]; 164 165 fread( hash2, 32, 1, stdin ); 166 if( memcmp( hash, hash2, 32 ) != 0 ) 167 { 168 fprintf( stderr, "Passwords don't match. Can't decode.\n" ); 169 return( 1 ); 170 } 171 func = deobfucrypt; 172 } 173 else 174 { 175 return( main( 0, NULL ) ); 176 } 177 178 while( fscanf( stdin, "%[^\n]255s", line ) > 0 ) 179 { 180 char *out; 181 182 /* Flush the newline */ 183 fgetc( stdin ); 184 185 out = func( line, argv[1] ); 186 printf( "%s\n", out ); 187 g_free( out ); 188 } 189 190 return( 0 ); 191 } 192 193 #endif
Note: See TracChangeset
for help on using the changeset viewer.