$30 off During Our Annual Pro Sale. View Details »
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
49
JSON Web Tokens in a microservice architecture (PHPBenelux)
jenssegers
0
520
JSON Web Tokens - PHP Antwerp
jenssegers
0
210
Testing API's with Behat
jenssegers
0
350
Apps for Ghent - Realo
jenssegers
0
320
An introduction to automated development environment and Laravel Homestead
jenssegers
0
240
Git 101
jenssegers
1
190
Other Decks in Technology
See All in Technology
履歴テーブル、今回はこう作りました 〜 Delegated Types編 〜 / How We Built Our History Table This Time — With Delegated Types
moznion
13
8.7k
AI エージェント活用のベストプラクティスと今後の課題
asei
2
420
LangChain v1.0にトライ~ AIエージェントアプリの移行(v0.3 → v1.0) ~
happysamurai294
0
140
Introduction to Bill One Development Engineer
sansan33
PRO
0
320
プロダクト負債と歩む持続可能なサービスを育てるための挑戦
sansantech
PRO
1
1.2k
タグ付きユニオン型を便利に使うテクニックとその注意点
uhyo
1
340
[続・営業向け 誰でも話せるOCI セールストーク] AWSよりOCIの優位性が分からない編(2025年11月21日開催)
oracle4engineer
PRO
1
180
一億総業務改善を支える社内AIエージェント基盤の要諦
yukukotani
7
2.2k
「え?!それ今ではHTMLだけでできるの!?」驚きの進化を遂げたモダンHTML
riyaamemiya
0
520
Master Dataグループ紹介資料
sansan33
PRO
1
4k
GitHub を組織的に使いこなすために ソニーが実践した全社展開のプラクティス
sony
19
10k
『ソフトウェア』で『リアル』を動かす:クレーンゲームからデータ基盤までの統一アーキテクチャ / アーキテクチャConference 2025
genda
0
2.4k
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
Visualization
eitanlees
150
16k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.8k
Agile that works and the tools we love
rasmusluckow
331
21k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
Designing Experiences People Love
moore
142
24k
Facilitating Awesome Meetings
lara
57
6.6k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.6k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
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