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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
ThetaOS - A Mythical Machine comes Alive
aslander
0
100
開発チームとQAエンジニアの新しい協業モデル -年末調整開発チームで実践する【QAリード施策】-
kaomi_wombat
0
230
めちゃくちゃ開発するQAエンジニアになって感じたメリットとこれからの課題感
ryuhei0000yamamoto
0
270
AlloyDB 奮闘記
hatappi
0
200
20260320_JaSST26_Tokyo_登壇資料.pdf
mura_shin
0
110
Phase03_ドキュメント管理
overflowinc
0
2.1k
Copilot 宇宙へ 〜生成AIで「専門データの壁」を壊す方法〜
nakasho
0
150
A4)シラバスを超えて語る、テストマネジメント
moritamasami
0
120
スピンアウト講座02_ファイル管理
overflowinc
0
1.1k
エンジニアリングマネージャーの仕事
yuheinakasaka
0
130
SLI/SLO 導入で 避けるべきこと3選
yagikota
0
140
Kiro Powers 入門
k_adachi_01
0
140
Featured
See All Featured
Code Review Best Practice
trishagee
74
20k
Abbi's Birthday
coloredviolet
2
5.6k
How to make the Groovebox
asonas
2
2k
Building Applications with DynamoDB
mza
96
7k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
650
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
250
What's in a price? How to price your products and services
michaelherold
247
13k
KATA
mclloyd
PRO
35
15k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
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