Hello,
I want to make hash which convert a number to string :
sth like:
input output
1 ahywde
2 yewnse
3 ewdsiq
random output!
6 replies to this topic
#1
Posted 20 January 2011 - 04:21 AM
|
|
|
#2
Posted 20 January 2011 - 05:06 AM
I am unsure if you wish to use existing function, this should provide a non-hexadecimal only hash.
<?php
$nums = array(1, 2, 3, 4, 5);
foreach($nums as $num)
echo "$num " , substr(strtolower(base64_encode(sha1($num))),0,6) . "\n";1 mzu2yt 2 n2i1mj 3 owu2og 4 ntnlyt 5 mne2mz
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#3
Posted 20 January 2011 - 05:19 AM
Does it work for how many number?
I want to change serial number to string but short one.
Note I have 3 field which should give me one hash!
Table strut
sid (Number that I want change it to string)
type (A Number between 20 number)
Name (String)
SN (String)
I want to change serial number to string but short one.
Note I have 3 field which should give me one hash!
Table strut
sid (Number that I want change it to string)
type (A Number between 20 number)
Name (String)
SN (String)
#4
Posted 20 January 2011 - 05:26 AM
You can simply concatenate the fields and pass it through my sha1 set of functions. It will work for any length string and return a short string out of it.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#5
Posted 20 January 2011 - 06:13 AM
Can you show how?
I don't know how to use it!
I don't know how to use it!
#6
Posted 20 January 2011 - 07:04 AM
All you need to do is make the query, and return the results, and combine them. A simple example:
Is that what you wanted?
function doHash($string) {
return substr(strtolower(base64_encode(sha1($string))), 0, 6);
}
$hashstr = "";
$query = mysql_query("SELECT (sid, type, Name, SN) FROM strut WHERE (...) ");
while($row = mysql_fetch_assoc($query) {
$hashstr = doHash($row['sid'] . $row['type'] . $row['Name'] . $row['SN']);
}
echo $hashstr;
Is that what you wanted?
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#7
Posted 20 January 2011 - 07:32 AM
yes,
This what I need!
+rep
This what I need!
+rep
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









