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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
幾億の壁を超えて/Beyond Countless Walls(JP)
ikuodanaka
0
130
ハーネスエンジニアリングの概要と設計思想
sergicalsix
3
520
サイボウズ 開発本部採用ピッチ / Cybozu Engineer Recruit
cybozuinsideout
PRO
10
78k
Data Hubグループ 紹介資料
sansan33
PRO
0
2.9k
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
16k
ワールドカフェI /チューターを改良する / World Café I and Improving the Tutors
ks91
PRO
0
240
生成AI時代のエンジニア育成 変わる時代と変わらないコト
starfish719
0
6.8k
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
4
23k
Amazon S3 Filesについて
yama3133
2
120
Databricksで構築するログ検索基盤とアーキテクチャ設計
cscengineer
0
190
ある製造業の会社全体のAI化に1エンジニアが挑んだ話
kitami
2
990
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4.2k
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
150
Embracing the Ebb and Flow
colly
88
5k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.8k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
720
Scaling GitHub
holman
464
140k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
99
Darren the Foodie - Storyboard
khoart
PRO
3
3.2k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Why You Should Never Use an ORM
jnunemaker
PRO
61
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