Linux/Linux_technic

Checksum과 md5sum / 파일 검사합

sosal 2014. 8. 12. 20:53
반응형

/*

 http://sosal.kr/
 * made by so_Sal
 */



- Checksum

전송받은 파일, 데이터의 정확성을 확인하기 위해 사용되는 검사 합으로 전송받은 데이터의 오류 유무를 검출하는 방식중 하나입니다. 자료처리의 정확성을 확인하기 위한 비트의 합계를 이용합니다.


- Checksum error

전송받은 파일, 데이터의 검사 합이 증명된 검사 합계와 일치하지 않는 경우에, 이를 검사합 에러(checksum error)라고 합니다.


하지만 checksum으로는 전송방식이 잘못 될 경우 checksum error를 내지 않지만 내용이 다를 수 있으므로, md5sum이라는 알고리즘을 사용합니다.


- md5sum

md5sum is a computer program that calculates and verifies 128-bit MD5 hashes, as described in RFC 1321. The MD5 hash (or checksum) functions as a compact digital fingerprint of a file. As with all such hashing algorithms, there is theoretically an unlimited number of files that will have any given MD5 hash. However, it is very unlikely that any two non-identical files in the real world will have the same MD5 hash, unless they have been specifically created to have the same hash.


md5sum는 해쉬값으로 sum을 계산하기 때문에, checksum이 잡아내지 못하는 오류를 찾아낼 수 있습니다.






- ex)

md5sum 예제로 ucsc Genome databank에서 SNP138-masked FASTA file을 사용해보았습니다.


http://hgdownload.soe.ucsc.edu/goldenPath/hg19/snp138Mask/





그중 하나인 fasta data 하나를 선택하여 다운받습니다.

전 chrX.subst.fa.gz 를 다운받았습니다.




wget http://hgdownload.soe.ucsc.edu/goldenPath/hg19/snp138Mask/chrX.subst.fa.gz





다운받은 파일의 check sum 값은 아래 파일에 저장되어 있습니다.

http://hgdownload.soe.ucsc.edu/goldenPath/hg19/snp138Mask/md5sum.txt

1e81dd82d64c5493264413b86f1b1217  chrX.subst.fa.gz



1e81dd82d64c5493264413b86f1b1217 ./chrX.subst.fa.gz
1e81dd82d64c5493264413b86f1b1217  chrX.subst.fa.gz


동일한 md5sum 값을 가지면 오류없이 파일을 받았다는것을 증명할 수 있습니다.