Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sha1(3) [php man page]

SHA1(3) 								 1								   SHA1(3)

sha1 - Calculate the sha1 hash of a string

SYNOPSIS
string sha1 (string $str, [bool $raw_output = false]) DESCRIPTION
Calculates the sha1 hash of $str using the US Secure Hash Algorithm 1. PARAMETERS
o $str - The input string. o $raw_output - If the optional $raw_output is set to TRUE, then the sha1 digest is instead returned in raw binary format with a length of 20, otherwise the returned value is a 40-character hexadecimal number. RETURN VALUES
Returns the sha1 hash as a string. EXAMPLES
Example #1 A sha1(3) example <?php $str = 'apple'; if (sha1($str) === 'd0be2dc421be4fcd0172e5afceea3970e2f3d940') { echo "Would you like a green or red apple?"; } ?> NOTES
Note Secure password hashing It is not recommended to use this function to secure passwords, due to the fast nature of this hashing algorithm. See here for details. SEE ALSO
sha1_file(3), crc32(3), md5(3), hash(3), crypt(3), password_hash(3). PHP Documentation Group SHA1(3)

Check Out this Related Man Page

MD5_FILE(3)								 1							       MD5_FILE(3)

md5_file - Calculates the md5 hash of a given file

SYNOPSIS
string md5_file (string $filename, [bool $raw_output = false]) DESCRIPTION
Calculates the MD5 hash of the file specified by the $filename parameter using the RSA Data Security, Inc. MD5 Message-Digest Algorithm, and returns that hash. The hash is a 32-character hexadecimal number. PARAMETERS
o $filename - The filename o $raw_output - When TRUE, returns the digest in raw binary format with a length of 16. RETURN VALUES
Returns a string on success, FALSE otherwise. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.1.0 | | | | | | | Changed the function to use the streams API. It | | | means that you can use it with wrappers, like | | | md5_file('http://example.com/..') | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 Usage example of md5_file(3) <?php $file = 'php-5.3.0alpha2-Win32-VC9-x64.zip'; echo 'MD5 file hash of ' . $file . ': ' . md5_file($file); ?> SEE ALSO
md5(3), sha1_file(3), crc32(3). PHP Documentation Group MD5_FILE(3)
Man Page

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

String Manipulation Question....

Say I've got a string like: data1,data2,data3,data4. How would I be able to break up the string, so that I have four variables w/ the values data1 data2 data3 data4. Also, how could I read a string character by character. I know you can read a sentence word by word by using the for var... (8 Replies)
Discussion started by: TheRocket
8 Replies

2. UNIX for Advanced & Expert Users

Delete a word and complete line

Hi Canone please provide me solution how can achieve the result below: File1.txt $ sweet appleŁ1 scotish green $ This is a test1 $ sweet mangoŁ2 asia yellow $ This is a test 2 $ sweet apple red (there is no pound symbol here) germany green (1 Reply)
Discussion started by: Aejaz
1 Replies

3. Shell Programming and Scripting

string checking

lets think str is a variable...how can i check it is pure alphabetic or not for numeric checking i have used echo $str|grep -v ] but the command echo $str|grep -v ] is not working (1 Reply)
Discussion started by: arghya_owen
1 Replies

4. Shell Programming and Scripting

How to remove space in sed for / character

Hi... i need a script to remove the space before and after the operator like( / ). Ex : Input file apple / manago mango / fresh apple / fresh Desired output: apple/manago mango/fresh apple/fresh Note: betwee the desired operator space should be removed, between words do not remove... (3 Replies)
Discussion started by: vasanth_vadalur
3 Replies

5. Red Hat

RHLE r4 and r5

Does anyone know how to verify which hashing algorithm is used to encrypt the passwords in /etc/shadow on red hat linux enterprise systems? or what the default hash setting is? Is there a file that stores this information? (1 Reply)
Discussion started by: stevej123
1 Replies

6. Programming

SHA1 hash calculation

hi i want to generate SHA1 hash of string in Linux (atmark) and downloaded the XYSSL-0.9 version code for the same.i have the algorithm which takes file as argument and returns hash of file . And of same file while I generated the key using online tools then it doesn't match with my compiled... (4 Replies)
Discussion started by: ahsaas42
4 Replies

7. UNIX for Dummies Questions & Answers

Mac OS X Password

I want to know the exact process of how Mac OS X takes a string(password) and encrypts it. I know the encrypted file is stored in /var/db/shadow/hash/<GUID> But.. 1) How does the string get to that point? 2) How can I write a script that can do this so i can encrypt my password, compare it... (0 Replies)
Discussion started by: cbreiny
0 Replies

8. Shell Programming and Scripting

sha1 question

What is the unix shell scripting equivalent of the following php code? I have tried to reproduce it, but I haven't been able to. <?php sha1(sha1(strtolower($user) . $pass) . $sessionid); ?> (12 Replies)
Discussion started by: locoroco
12 Replies

9. Shell Programming and Scripting

How to get the correct hash value in perl?

Hi, I have 2 dummy strings below. I am creating a hash. @str = qw(karnataka,tamilnadu,bihar,mumbai); @str1 = qw(bangalore,chennai,patna,panaji); %hash; for($i=0;$i<=$#str;$i++) { push @{ $hash{ $str } }, $str1; } foreach $key (keys %hash) { print "\n KEY: $key --- @{$hash{$key}}... (5 Replies)
Discussion started by: vanitham
5 Replies

10. Shell Programming and Scripting

Preserve trailing whitespace in variable

Hello, I wondering how I can echo a string without having the trailing whitespace removed. For example I have a string str="TESTING123 " that I need to hash using sha1. I get the correct answer when I run the line below from the terminal $ echo -n "TESTING123 " | openssl sha1... (3 Replies)
Discussion started by: colinireland
3 Replies