問(wèn)題描述
我正在尋找一個(gè) PHP 函數(shù),它可以從字符串或文件中創(chuàng)建一個(gè)簡(jiǎn)短的散列,類(lèi)似于那些 URL 縮短網(wǎng)站,如 tinyurl.com
I am looking for a PHP function that creates a short hash out of a string or a file, similar to those URL-shortening websites like tinyurl.com
哈希不應(yīng)超過(guò) 8 個(gè)字符.
The hash should not be longer than 8 characters.
推薦答案
URL 縮短服務(wù),而是使用自動(dòng)遞增的整數(shù)值(如補(bǔ)充數(shù)據(jù)庫(kù) ID)并使用 Base64 或其他編碼,以便為每個(gè)字符提供更多信息(64 而不是像數(shù)字一樣只有 10 個(gè)).
URL shortening services rather use a auto incremented integer value (like a supplementary database ID) and encode that with Base64 or other encodings to have more information per character (64 instead of just 10 like digits).
這篇關(guān)于PHP 短哈希,如 URL 縮短網(wǎng)站的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!