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
150
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
72
JSON Web Tokens in a microservice architecture (PHPBenelux)
jenssegers
0
560
JSON Web Tokens - PHP Antwerp
jenssegers
0
220
Testing API's with Behat
jenssegers
0
380
Apps for Ghent - Realo
jenssegers
0
330
An introduction to automated development environment and Laravel Homestead
jenssegers
0
250
Git 101
jenssegers
1
200
Other Decks in Technology
See All in Technology
地域 SRE コミュニティ最前線 / SRE NEXT 2026 Discussion Night Track C
muziyoshiz
0
200
「最後に責任を取るのはチーム」— 人間のPRレビューを最小化してアップデートしたメンタルモデル
jnishime_dresscode
0
130
しくみを学んで使いこなそう GitHub Copilot app
torumakabe
1
180
デジタル・デザイン構想 by Sayaka Ishizuka
y150saya
0
200
依頼文化をやめる日 EM視点で語るPlatform EngineeringとInclusive SRE / Discussing Platform Engineering and Inclusive SRE from an EM's Perspective
shin1988
4
5k
Mastraエージェント、どのクラウドにデプロイする?
minorun365
PRO
2
180
キャリアの中で本を作る / Making a Book During Your Career
ak1210
0
130
知らん間に、回ってる
ming_ayami
0
380
グローバルチームと挑むプロダクト開発
sansantech
PRO
1
170
証券システムを10年Scalaで作り続けるということ - 関数型まつり2026
krrrr38
3
830
プライバシー保護の理論と実践
lycorptech_jp
PRO
1
250
「ちゃんとやっている」は独りよがりだった ― 不安に寄り添うインシデント対応へ / Towards incident response that addresses anxieties
chmikata
1
4.6k
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
630
For a Future-Friendly Web
brad_frost
183
10k
Embracing the Ebb and Flow
colly
88
5.1k
How to Talk to Developers About Accessibility
jct
2
300
Optimising Largest Contentful Paint
csswizardry
37
3.8k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
550
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
67
56k
Designing for Timeless Needs
cassininazir
1
290
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
420
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
220
Un-Boring Meetings
codingconduct
0
340
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