Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on File Checksums within the PHP forums, part of the Web Development category; Hi what is exactly the purpose of sha1_file function, how the string it returns is useful ?I've tried to understand the example which has been given in the manual but ...
|
|||||||
| PHP PHP - The most popular scripting language. Discuss PHP related questions here. Sample Scripts, Popular downloads, tools and utilites and more... |
![]() |
| LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi
what is exactly the purpose of sha1_file function, how the string it returns is useful ?I've tried to understand the example which has been given in the manual but i am unable to get through it,can anybody explain in simple words? |
| Sponsored Links |
|
|||
|
Re: File Checksums
Hi,
Did u have an idea of US Secure Hash Algorithm 1. ????? US Secure hash algorithm 1 The US secure hash algorithm 1: "sha-1 produces a 160-bit output called a message digest. The message digest can then, for example, be input to a signature algorithm which generates or verifies the signature for the message. Signing the message digest rather than the message often improves the efficiency of the process because the message digest is usually much smaller in size than the message. The same hash algorithm must be used by the verifier of a digital signature as was used by the creator of the digital signature." the sha1_file() function calculates the sha-1 hash of a file.. It uses the us secure hash algorithm 1. syntax :sha1_file(file,raw) I'll give u an example.... <?php $sha1file = file_get_contents("sha1file.txt"); if (sha1_file("test.txt") == $sha1file) { echo "Hello,Welcome to geekinterview.com"; } else { echo "Goodbye"; } ?> The output of the code above could be: Hello,Welcome to geekinterview.com I think its enough to resolve u r query, if any .... Let me know... Thanks & Regards, Riju. Last edited by rijus; 07-28-2009 at 12:03 PM. |
| The Following User Says Thank You to rijus For This Useful Post: | ||
|
|||
|
Re: File Checksums
Hi,
Thanks for you help Riju.I have some basic idea about US secure hashing Algorithm,maybe i haven't explained my querry proerly before,but still you reply was of gr8 help. If i m not wrong, sha1_file can be used to check whether a file has been downloaded properly or not?... below, i m quoting some simple code,the filename given as parameter, is a webpage i have downloaded and saved on my desktop. $sha1_val1 =sha1(.../sha1_test.htm")); $sha1_val2 =sha1_file(".../sha1_test.htm"); echo $sha1_val1."<br>"; echo $sha1_val2."<br>"; if($sha1_val1==$sha1_val2) { print "file contents matched<br>"; } else { print "file contents did not match<br>"; } Above code is working fine and shows that file contents match.I just want you to tell me whether i m doing correctly(logically) or not?, Is this the way we can check whether file has been downloaded correctly or is there another method. Thanks for your help, Regards, Saara |
|
|||
|
Re: File Checksums
Hi,
Yes U r correct. It's a simple method & the the code also works fine .So it can be used to chek whether a file has been downloaded correctly or not. Just Go a head... If any pblm we all r here to help u out. Regards, Riju. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Convert dbf file to ASCII (text) file | mohit1211 | Oracle | 2 | 02-17-2008 11:54 PM |
| Use of export xml file and import xml file options | naags | QTP | 1 | 07-19-2007 02:37 PM |
| Steps for deploying a war file/ear file on websphere | Sujatars | Java | 0 | 07-19-2007 12:49 AM |
| How do I 'unpack' and view a .FILE vsam file | Geek_Guest | MainFrame | 0 | 06-26-2007 09:22 PM |
| Frigate3 File Manager: highly configurable and convenient file management environment | JobHelper | Geeks Lounge | 0 | 03-30-2007 03:30 PM |