應用遠程代碼怎么實作外部檔案加密外部檔案
uj5u.com熱心網友回復:
參考 樓主 weixin_44165171的回復: 應用遠程代碼怎么實作外部檔案加密外部檔案
</pre><pre name="code" class="java">package ********//
<span style="color:#33cc00;">自己定義</span>;
import java.io.File;
import java.io.RandomAccessFile;
import java.util.Scanner;
public class Test1 {
public static void main(String[] args) {
System.out.println("輸入檔案路徑:");
String s = new Scanner(System.in).nextLine();
File f =new File(s);
if(!f.isFile()){
System.out.println("請輸入正確的檔案路徑");
return ;
}
System.out.println("KEY:");
int key =new Scanner(System.in).nextInt();
try {
encrypt(f,key);
System.out.println("加密/解密完成");
} catch (Exception e) {
System.out.println("加密/解密失敗");
e.printStackTrace();
}
}
private static void encrypt(File f, int key) throws Exception{
/*
* 1.新建RandomAccessFile 物件賦給raf
* 2.單位元組回圈讀取,讀取的位元組值賦給b
* 3.b異或key,結果在賦給b
* 4.定位下標回到前一位置seek(raf.getFilePointer()-1)
* 5.將位元組值b 寫回到的檔案
* 6.關閉raf
這種不能用吧?
uj5u.com熱心網友回復:
參考 1 樓 weixin_44165171的回復: Quote: 參考 樓主 weixin_44165171的回復: 應用遠程代碼怎么實作外部檔案加密外部檔案
</pre><pre name="code" class="java">package ********//
<span style="color:#33cc00;">自己定義</span>;
import java.io.File;
import java.io.RandomAccessFile;
import java.util.Scanner;
public class Test1 {
public static void main(String[] args) {
System.out.println("輸入檔案路徑:");
String s = new Scanner(System.in).nextLine();
File f =new File(s);
if(!f.isFile()){
System.out.println("請輸入正確的檔案路徑");
return ;
}
System.out.println("KEY:");
int key =new Scanner(System.in).nextInt();
try {
encrypt(f,key);
System.out.println("加密/解密完成");
} catch (Exception e) {
System.out.println("加密/解密失敗");
e.printStackTrace();
}
}
private static void encrypt(File f, int key) throws Exception{
/*
* 1.新建RandomAccessFile 物件賦給raf
* 2.單位元組回圈讀取,讀取的位元組值賦給b
* 3.b異或key,結果在賦給b
* 4.定位下標回到前一位置seek(raf.getFilePointer()-1)
* 5.將位元組值b 寫回到的檔案
* 6.關閉raf
這種不能用吧?
看一下,還不知道??????
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/67330.html
標籤:Android
上一篇:arduino telent
下一篇:【求助】利用Android studio畫動態曲線