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
130
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
54
JSON Web Tokens in a microservice architecture (PHPBenelux)
jenssegers
0
530
JSON Web Tokens - PHP Antwerp
jenssegers
0
210
Testing API's with Behat
jenssegers
0
360
Apps for Ghent - Realo
jenssegers
0
320
An introduction to automated development environment and Laravel Homestead
jenssegers
0
240
Git 101
jenssegers
1
190
Other Decks in Technology
See All in Technology
ファインディにおけるフロントエンド技術選定の歴史
puku0x
2
1.5k
OCI技術資料 : OS管理ハブ 概要
ocise
2
4.1k
新米スクラムマスターの4ヶ月 -「スクラムイベントを回しているのに手応えがない」からの脱出 / Four Months as a New Scrum Master — When Scrum Events Were Running, but Nothing Felt Right
owata
0
180
Digitization部 紹介資料
sansan33
PRO
1
6.6k
Vivre en Bitcoin : le tutoriel que votre banquier ne veut pas que vous voyiez
rlifchitz
0
310
旬のブリと旬の技術で楽しむ AI エージェント設計開発レシピ
chack411
1
290
The Engineer with a Three-Year Cycle
e99h2121
0
150
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
4
22k
会社紹介資料 / Sansan Company Profile
sansan33
PRO
12
400k
Oracle Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
3
390
産業的変化も組織的変化も乗り越えられるチームへの成長 〜チームの変化から見出す明るい未来〜
kakehashi
PRO
1
790
サラリーマンソフトウェアエンジニアのキャリア
yuheinakasaka
41
19k
Featured
See All Featured
RailsConf 2023
tenderlove
30
1.3k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Between Models and Reality
mayunak
1
170
Google's AI Overviews - The New Search
badams
0
890
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Rails Girls Zürich Keynote
gr2m
95
14k
Scaling GitHub
holman
464
140k
From π to Pie charts
rasagy
0
120
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
87
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.2k
YesSQL, Process and Tooling at Scale
rocio
174
15k
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