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
120
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
41
JSON Web Tokens in a microservice architecture (PHPBenelux)
jenssegers
0
500
JSON Web Tokens - PHP Antwerp
jenssegers
0
200
Testing API's with Behat
jenssegers
0
320
Apps for Ghent - Realo
jenssegers
0
310
An introduction to automated development environment and Laravel Homestead
jenssegers
0
230
Git 101
jenssegers
1
180
Other Decks in Technology
See All in Technology
経理出身PdMがAIプロダクト開発を_ハンズオンで学んだ話.pdf
shunsukenarita
1
110
M365アカウント侵害時の初動対応
lhazy
7
4.5k
「AI駆動開発」のボトルネック『言語化』を効率化するには
taniiicom
1
100
20150719_Amazon Nova Canvas Virtual try-onアプリ 作成裏話
riz3f7
0
130
AI Ready API ─ AI時代に求められるAPI設計とは?/ AI-Ready API - Designing MCP and APIs in the AI Era
yokawasa
21
5.8k
Webの技術とガジェットで那須の子ども達にワクワクを! / IoTLT_20250720
you
PRO
0
120
AI工学特論: MLOps・継続的評価
asei
10
1.6k
機械学習を「社会実装」するということ 2025年夏版 / Social Implementation of Machine Learning July 2025 Version
moepy_stats
1
590
怖くない!GritQLでBiomeプラグインを作ろうよ
pal4de
1
120
TROCCO今昔
gtnao
0
210
本当にわかりやすいAIエージェント入門
segavvy
10
5.9k
Building GoReleaser - from shell script to paid product
caarlos0
0
270
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1370
200k
Facilitating Awesome Meetings
lara
54
6.5k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
A better future with KSS
kneath
238
17k
Building Adaptive Systems
keathley
43
2.7k
BBQ
matthewcrist
89
9.7k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Code Review Best Practice
trishagee
69
19k
Practical Orchestrator
shlominoach
189
11k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Unsuck your backbone
ammeep
671
58k
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