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
30
JSON Web Tokens in a microservice architecture (PHPBenelux)
jenssegers
0
440
JSON Web Tokens - PHP Antwerp
jenssegers
0
180
Testing API's with Behat
jenssegers
0
260
Apps for Ghent - Realo
jenssegers
0
270
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
ドメイン名の終活について - JPAAWG 7th -
mikit
33
20k
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.4k
【Startup CTO of the Year 2024 / Audience Award】アセンド取締役CTO 丹羽健
niwatakeru
0
990
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
360
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
0
110
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
350
The Rise of LLMOps
asei
7
1.4k
複雑なState管理からの脱却
sansantech
PRO
1
140
Platform Engineering for Software Developers and Architects
syntasso
1
520
スクラム成熟度セルフチェックツールを作って得た学びとその活用法
coincheck_recruit
1
140
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Visualization
eitanlees
145
15k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Building an army of robots
kneath
302
43k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
89
Agile that works and the tools we love
rasmusluckow
327
21k
Building Applications with DynamoDB
mza
90
6.1k
Done Done
chrislema
181
16k
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