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
130
2
Share
Hashids and Perceptual hashes
PHP Ghent presentation
Jens Segers
April 29, 2015
More Decks by Jens Segers
See All by Jens Segers
Building a digital ID card for authentication
jenssegers
0
61
JSON Web Tokens in a microservice architecture (PHPBenelux)
jenssegers
0
550
JSON Web Tokens - PHP Antwerp
jenssegers
0
220
Testing API's with Behat
jenssegers
0
370
Apps for Ghent - Realo
jenssegers
0
330
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
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.4k
Azure PortalなどにみるWebアクセシビリティ
tomokusaba
0
330
目的ファーストのハーネス設計 ~ハーネスの変更容易性を高めるための優先順位~
gotalab555
2
480
【Findy FDE登壇_2026_04_14】— 現場課題を本気で解いてたら、FDEになってた話
miyatakoji
0
1.1k
Proxmox超入門
devops_vtj
0
220
The Journey of Box Building
tagomoris
2
120
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.1k
ルールルルルル私的函館観光ガイド── 函館の街はイクラでも楽しめる!
nomuson
0
200
システムは「動く」だけでは足りない 実装編 - 非機能要件・分散システム・トレードオフをコードで見る
nwiizo
4
400
サイボウズ 開発本部採用ピッチ / Cybozu Engineer Recruit
cybozuinsideout
PRO
10
78k
職能の壁を取り払った先で見えた壁 -AI時代のクロスファンクショナル組織-
shimotaroo
1
100
Rebirth of Software Craftsmanship in the AI Era
lemiorhan
PRO
3
1.2k
Featured
See All Featured
Practical Orchestrator
shlominoach
191
11k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
170
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
790
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
Become a Pro
speakerdeck
PRO
31
5.9k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
180
A Tale of Four Properties
chriscoyier
163
24k
Chasing Engaging Ingredients in Design
codingconduct
0
170
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Designing Experiences People Love
moore
143
24k
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