<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    運行:regsvr32 c:\windows\system32\hhctrl.ocx

    package ?des;?

    import ?java.io. * ;?
    import ?java.nio. * ;?
    import ?java.nio.channels.FileChannel;?

    public ? class ?FileDES{?
    private ? static ? final ? boolean ?enc = true ;? // 加密?
    private ? static ? final ? boolean ?dec = false ;? // 解密?

    private ?String?srcFileName;?
    private ?String?destFileName;?
    private ?String?inKey;?
    private ? boolean ?actionType;?
    private ?File?srcFile;?
    private ?File?destFile;?
    private ?Des?des;?

    private ? void ?analyzePath(){?
    String?dirName;?
    int ?pos = srcFileName.lastIndexOf( " / " );?
    dirName
    = srcFileName.substring( 0 ,pos);?
    File?dir
    = new ?File(dirName);?
    if ?( ! dir.exists()){?
    System.err.println(dirName
    + " ?is?not?exist " );?
    System.exit(
    1 );?
    }
    else ? if ( ! dir.isDirectory()){?
    System.err.println(dirName
    + " ?is?not?a?directory " );?
    System.exit(
    1 );?
    }?

    pos
    = destFileName.lastIndexOf( " / " );?
    dirName
    = destFileName.substring( 0 ,pos);?
    dir
    = new ?File(dirName);?
    if ?( ! dir.exists()){?
    if ( ! dir.mkdirs()){?
    System.out.println?(
    " can?not?creat?directory: " + dirName);?
    System.exit(
    1 );?
    }?
    }
    else ? if ( ! dir.isDirectory()){?
    System.err.println(dirName
    + " ?is?not?a?directory " );?
    System.exit(
    1 );?
    }?
    }?

    private ? static ? int ?replenish(FileChannel?channel,ByteBuffer?buf)? throws ?IOException{?
    long ?byteLeft = channel.size() - channel.position();?
    if (byteLeft == 0L )?
    return ? - 1 ;?
    buf.position(
    0 );?
    buf.limit(buf.position()
    + (byteLeft < 8 ? ? ?( int )byteLeft?: 8 ));?
    return ?channel.read(buf);?
    }?

    private ? void ?file_operate( boolean ?flag){?
    des
    = new ?Des(inKey);?
    FileOutputStream?outputFile
    = null ;?
    try ?{?
    outputFile
    = new ?FileOutputStream(srcFile, true );?
    }
    catch ?(java.io.FileNotFoundException?e)?{?
    e.printStackTrace(System.err);?
    }?
    FileChannel?outChannel
    = outputFile.getChannel();?

    try {?
    if (outChannel.size() % 2 != 0 ){?
    ByteBuffer?bufTemp
    = ByteBuffer.allocate( 1 );?
    bufTemp.put((
    byte ) 32 );?
    bufTemp.flip();?
    outChannel.position(outChannel.size());?
    outChannel.write(bufTemp);?
    bufTemp.clear();?
    }?
    }
    catch (Exception?ex){?
    ex.printStackTrace(System.err);?
    System.exit(
    1 );?
    }?
    FileInputStream?inFile
    = null ;?
    try {?
    inFile
    = new ?FileInputStream(srcFile);?
    }
    catch (java.io.FileNotFoundException?e){?
    e.printStackTrace(System.err);?
    // System.exit(1);?
    }?
    outputFile
    = null ;?
    try ?{?
    outputFile
    = new ?FileOutputStream(destFile, true );?
    }
    catch ?(java.io.FileNotFoundException?e)?{?
    e.printStackTrace(System.err);?
    }?

    FileChannel?inChannel
    = inFile.getChannel();?
    outChannel
    = outputFile.getChannel();?


    ByteBuffer?inBuf
    = ByteBuffer.allocate( 8 );?
    ByteBuffer?outBuf
    = ByteBuffer.allocate( 8 );?

    try {?
    String?srcStr;?
    String?destStr;?
    while ( true ){?

    if ?(replenish(inChannel,inBuf) ==- 1 )? break ;?
    srcStr
    = ((ByteBuffer)(inBuf.flip())).asCharBuffer().toString();?
    inBuf.clear();?
    if ?(flag)?
    destStr
    = des.enc(srcStr,srcStr.length());?
    else ?
    destStr
    = des.dec(srcStr,srcStr.length());?
    outBuf.clear();?
    if ?(destStr.length() == 4 ){?
    for ?( int ?i? = ? 0 ;?i < 4 ;?i ++ )?{?
    outBuf.putChar(destStr.charAt(i));?
    }?
    outBuf.flip();?
    }
    else {?
    outBuf.position(
    0 );?
    outBuf.limit(
    2 * destStr.length());?
    for ?( int ?i? = ? 0 ;?i < destStr.length();?i ++ )?{?
    outBuf.putChar(destStr.charAt(i));?
    }?
    outBuf.flip();?
    }?

    try ?{?
    outChannel.write(outBuf);?
    outBuf.clear();?
    }
    catch ?(java.io.IOException?ex)?{?
    ex.printStackTrace(System.err);?
    }?
    }?
    System.out.println?(inChannel.size());?
    System.out.println?(outChannel.size());?
    System.out.println?(
    " EoF?reached. " );?
    inFile.close();?
    outputFile.close();?
    }
    catch (java.io.IOException?e){?
    e.printStackTrace(System.err);?
    System.exit(
    1 );?
    }?
    }?

    public ?FileDES(String?srcFileName,String?destFileName,String?inKey, boolean ?actionType){?
    this .srcFileName = srcFileName;?
    this .destFileName = destFileName;?
    this .actionType = actionType;?
    analyzePath();?
    srcFile
    = new ?File(srcFileName);?
    destFile
    = new ?File(destFileName);?
    this .inKey = inKey;?
    if ?(actionType == enc)?
    file_operate(enc);?
    else ?
    file_operate(dec);?
    }?


    public ? static ? void ?main(String[]?args){?
    String?file1
    = System.getProperty( " user.dir " ) + " /111.doc " ;?
    String?file2
    = System.getProperty( " user.dir " ) + " /222.doc " ;?
    String?file3
    = System.getProperty( " user.dir " ) + " /333.doc " ;?
    String?passWord
    = " 1234ABCD " ;?
    FileDES?fileDes
    = new ?FileDES(file1,file2,passWord, true );?
    FileDES?fileDes1
    = new ?FileDES(file2,file3,passWord, false );?
    }
    posted on 2006-07-01 21:37 pear 閱讀(567) 評論(0)  編輯  收藏 所屬分類: 技術
     
    主站蜘蛛池模板: 亚洲午夜无码久久久久软件| 久久久久久亚洲av成人无码国产| 亚洲av专区无码观看精品天堂| 91免费国产视频| 在线a亚洲v天堂网2019无码| 精品免费久久久久国产一区| 亚洲午夜国产精品无码| 在线看片免费人成视频福利| 亚洲五月六月丁香激情| 最近中文字幕完整版免费高清| 亚洲精品国产成人中文| 免费一本色道久久一区| 亚洲av成人一区二区三区在线播放| 永久免费毛片手机版在线看| 另类图片亚洲校园小说区| 亚洲人成色7777在线观看不卡| 91精品成人免费国产| 久久精品国产亚洲av成人| 真人做A免费观看| 亚洲国产精品一区二区三区在线观看 | 色噜噜综合亚洲av中文无码| 一区二区在线免费观看| 国产一区二区三区亚洲综合| 俄罗斯极品美女毛片免费播放| 国产99久久亚洲综合精品| 亚洲日韩aⅴ在线视频| 在线免费观看国产| 亚洲AV成人影视在线观看| 免费a级毛片大学生免费观看| 国产免费久久精品丫丫| 亚洲精彩视频在线观看| 国产免费啪嗒啪嗒视频看看| 一级做a爰性色毛片免费| 亚洲激情黄色小说| 四虎影视永久免费视频观看| 国产精品一区二区三区免费| 国产在线观看免费不卡| 久久免费高清视频| 亚洲中文字幕久久精品无码A| 久久亚洲高清综合| 黄色成人免费网站|