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
110
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
33
JSON Web Tokens in a microservice architecture (PHPBenelux)
jenssegers
0
460
JSON Web Tokens - PHP Antwerp
jenssegers
0
180
Testing API's with Behat
jenssegers
0
280
Apps for Ghent - Realo
jenssegers
0
290
An introduction to automated development environment and Laravel Homestead
jenssegers
0
210
Git 101
jenssegers
1
170
Other Decks in Technology
See All in Technology
GitLab SelfManagedをCodePipelineのソースに設定する/SetGitLabSelfManagedtoCodePipeline
norihiroishiyama
1
110
2025-01-24-SRETT11-OpenTofuについてそろそろ調べてみるか
masasuzu
0
170
MicrosoftのOSSだけでAIによるブラウザテストを構成する
ymd65536
1
240
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
17k
20250129 Findy_テスト高活用化
dshirae
0
190
ココナラのセキュリティ組織の体制・役割・今後目指す世界
coconala_engineer
0
200
Mocking your codebase without cursing it
gaqzi
0
150
スクラムマスターの活動と組織からの期待のズレへの対応 / Dealing with the gap between Scrum Master activities and organizational expectations
pauli
2
1k
GraphRAG: What I Thought I Knew (But Didn’t)
sashimimochi
1
150
大学教員が押さえておくべき生成 AI の基礎と活用例〜より効率的な教育のために〜
soh9834
1
180
消し忘れリソースゼロへ!私のResource Explorer活用法
cuorain
0
130
バクラクの組織とアーキテクチャ(要約)2025/01版
shkomine
8
1.3k
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
98
18k
Fireside Chat
paigeccino
34
3.2k
Bash Introduction
62gerente
610
210k
Thoughts on Productivity
jonyablonski
68
4.4k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
Facilitating Awesome Meetings
lara
51
6.2k
4 Signs Your Business is Dying
shpigford
182
22k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.8k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
980
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Measuring & Analyzing Core Web Vitals
bluesmoon
5
220
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