91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 4KB
    文件類型: .java
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-11
  • 語言: Java
  • 標(biāo)簽: 單表??加密??java??

資源簡介

單表代換加密算法的java實(shí)現(xiàn),僅限于對英文.txt文檔的加密

資源截圖

代碼片段和文件信息


//在計(jì)算機(jī)中,我們可以將文件分為文本文件(text?file)和二進(jìn)制文件(binary?file)兩種。
//文本文件中只包含字母、數(shù)字、標(biāo)點(diǎn)及一些特殊字符,這些字符有一個共同點(diǎn),
//它們最多只有7位有效編碼,即使用8位編碼格式的字節(jié)中最高位為0,
//我們也常將這種文件稱為ASCII文件。
//二進(jìn)制文件中則可以包括任意數(shù)據(jù),所以它的數(shù)據(jù)字節(jié)中常常有最高位為1的字節(jié),
//即它的8位字節(jié)編碼都是有效的。

import?java.io.*;

public?class?Monoalphabetic?{
private?String?srcFilePath;
private?String?prnPath;

public?Monoalphabetic(String?filePathString?parentPath){
this.srcFilePath?=?filePath;
this.prnPath?=?parentPath;
}

public?void?cipher(){
try{
???????? File?sourceFile?=?new?File(srcFilePath);

???????? File?outFile?=?new?File(prnPath+“\\Monoalphabetic?encryption.txt“);
outFile.createNewFile();

//實(shí)現(xiàn)方案1:用BufferedReader一個字符一個字符讀寫
//???????? BufferedReader?in?=?new?BufferedReader(new?FileReader(sourceFile));
// BufferedWriter?out?=?new?BufferedWriter(new?FileWriter(outFile));
//???????? int?inChar;
//???????? while((inChar=in.read())!=-1){
//???????? inChar++;
//???????? out.write(inChar);
//???????? }
//???????? in.close();
//???????? out.close();
????????
???????? //實(shí)現(xiàn)方案2:用RandomAccessFile一個字符一個字符讀寫
//???????? RandomAccessFile?sf?=?new?RandomAccessFile(sourceFile?“rw“);
//???? RandomAccessFile?of?=?new?RandomAccessFile(outFile?“rw“);
// char?inChar;
// while(sf.getFilePointer()// inChar?=?sf.readChar();
// of.writeChar(inChar);
// System.out.println(inChar);
//// inChar?=?sf.readLine(); //或者整行讀寫,再對String?inChar進(jìn)行操作
//// of.writeChars(inChar+“?“);
// }
// sf.close();
// of.close();
?

//??solution?3:?assuming?that?we?only?need?to?access?data?from?.txt?files
???????? RandomAccessFile?sf?=?new?RandomAccessFile(sourceFile?“r“);
???? RandomAccessFile?of?=?new?RandomAccessFile(outFile?“rw“);


評論

共有 條評論