SHA1(3) 1 SHA1(3)sha1 - Calculate the sha1 hash of a stringSYNOPSIS
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 fileSYNOPSIS
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)