Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Hashids and Perceptual hashes
Search
Jens Segers
April 29, 2015
Technology
2
130
Hashids and Perceptual hashes
PHP Ghent presentation
Jens Segers
April 29, 2015
Tweet
Share
More Decks by Jens Segers
See All by Jens Segers
Building a digital ID card for authentication
jenssegers
0
58
JSON Web Tokens in a microservice architecture (PHPBenelux)
jenssegers
0
540
JSON Web Tokens - PHP Antwerp
jenssegers
0
220
Testing API's with Behat
jenssegers
0
370
Apps for Ghent - Realo
jenssegers
0
320
An introduction to automated development environment and Laravel Homestead
jenssegers
0
250
Git 101
jenssegers
1
190
Other Decks in Technology
See All in Technology
脳が溶けた話 / Melted Brain
keisuke69
1
770
DMBOKを使ってレバレジーズのデータマネジメントを評価した
leveragestech
0
130
Phase03_ドキュメント管理
overflowinc
0
2.1k
生成AI活用でQAエンジニアにどのような仕事が生まれるか/Support Required of QA Engineers for Generative AI
goyoki
1
370
20年以上続く PHP 大規模プロダクトを Kubernetes へ ── クラウド基盤刷新プロジェクトの4年間
oogfranz
PRO
0
160
20260321_エンベディングってなに?RAGってなに?エンベディングの説明とGemini Embedding 2 の紹介
tsho
0
150
Phase09_自動化_仕組み化
overflowinc
0
1.4k
データマネジメント戦略Night - 4社のリアルを語る会
ktatsuya
1
120
ソフトバンク流!プラットフォームエンジニアリング実現へのアプローチ
sbtechnight
1
250
Phase04_ターミナル基礎
overflowinc
0
1.9k
Phase11_戦略的AI経営
overflowinc
0
1.3k
コンテキスト・ハーネスエンジニアリングの現在
hirosatogamo
PRO
6
740
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
Designing Experiences People Love
moore
143
24k
The Spectacular Lies of Maps
axbom
PRO
1
640
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
330
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
93
Ethics towards AI in product and experience design
skipperchong
2
230
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.5k
Designing for Timeless Needs
cassininazir
0
170
Typedesign – Prime Four
hannesfritz
42
3k
Transcript
None
@jenssegers Jens Segers
Hashids hashids/hashids
youtube.com/watch?v=dQw4w9WgXcQ
Why id obfuscation? Hiding application internals Reduces chance for URL
guessing Hide number of users, articles, … More difficult for scrapers
Encoding ids $hashids = new Hashids\Hashids('salt'); $encodedId = $hashids->encode(123); $hashids
= new Hashids\Hashids('salt'); $decodedId = $hashids->decode('Mj3')[0]; Decoding ids
Perceptual hashes jenssegers/imagehash
Removing thumbnails and duplicate images
#b40b2980dcbd08a #c1e9ee950f0e56cc Different from cryptographic hashing
Perceptual fingerprint No avalanche effect Comparing hashes Similar images =
similar hashes
Hamming Distance Number of different individual bits gmp_hamdist(0b10100110001, 0b10100110101) =
1
None
None
None
None
0000000000000010000000110000011100001111000111110110111111111111
0000000000000010000000110000011100001111000111110110111111111111 1011000110001000111110000000010100100111110100000100010100001010
Calculating the hash Using a different implementation: use Jenssegers\ImageHash\ImageHash; $hasher
= new ImageHash; $hash = $hasher->hash('path/to/image.jpg'); use Jenssegers\ImageHash\Implementation\AverageHash; $hasher = new ImageHash(new AverageHash); $hash = $hasher->hash('path/to/image.jpg');
Comparing hashes Or use your database: $d = $hasher->compare('image1.jpg', 'image2.jpg');
$d = $hasher->distance($hash1, $hash2); SELECT BIT_COUNT(hash ^ :hash) as hamming_distance FROM images HAVING hamming_distance < 5
@jenssegers Jens Segers