Premier commit - Inclusion dans le système git
This commit is contained in:
commit
f92798f4ae
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
bin/
|
||||||
47
src/com/bernard/exfatdemerde/ExfatChecksumCalculator.java
Normal file
47
src/com/bernard/exfatdemerde/ExfatChecksumCalculator.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package com.bernard.exfatdemerde;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class ExfatChecksumCalculator {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
System.out.println("Chemin du fichier ?");
|
||||||
|
File f = new File(sc.nextLine());
|
||||||
|
if(!f.exists()) {
|
||||||
|
System.err.println("ERREUR: le fichier spécifié est introuvable");sc.close();return;
|
||||||
|
}
|
||||||
|
System.out.println("Nombre de bytes par secteur ?");
|
||||||
|
int byteCount = 11*sc.nextInt();
|
||||||
|
System.out.println("Lecture de "+byteCount+" octets");
|
||||||
|
|
||||||
|
try (FileInputStream fis = new FileInputStream(f)){
|
||||||
|
byte[] data = new byte[byteCount];
|
||||||
|
fis.read(data);
|
||||||
|
int checksum = exfatBootChecksum(data, byteCount);
|
||||||
|
System.out.println("Voila la checksum que j'ai calculée :");
|
||||||
|
System.out.println(Integer.toString(checksum));
|
||||||
|
System.out.println("0x"+Integer.toHexString(checksum));
|
||||||
|
}catch(IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("\n\nTadaaaaaaaaaa");
|
||||||
|
sc.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int exfatBootChecksum(byte[] data, long bytes){
|
||||||
|
int checksum = 0;
|
||||||
|
for (int i = 0 ; i < bytes ; i++){
|
||||||
|
if (i == 106 || i == 107 || i == 112)
|
||||||
|
continue;
|
||||||
|
checksum = ((byte)((checksum&0xFF) << 31)) | (((byte)((checksum&0xFF) >> 1)) + ((byte)(data[i]&0xFF)));
|
||||||
|
//System.out.println("Checksum :"+Integer.toHexString(checksum));
|
||||||
|
}
|
||||||
|
return checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user