Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Speedtest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
noc
Speedtest
Commits
ab865caa
Commit
ab865caa
authored
6 years ago
by
adolfintel
Browse files
Options
Downloads
Patches
Plain Diff
Merged with master
parent
e01f4fa4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Frontend/telemetry/idObfuscation.php
+11
-8
11 additions, 8 deletions
Frontend/telemetry/idObfuscation.php
with
11 additions
and
8 deletions
Frontend/telemetry/idObfuscation.php
+
11
−
8
View file @
ab865caa
...
...
@@ -18,22 +18,25 @@ function getObfuscationSalt(){
This is a simple reversible hash function I made for encoding and decoding test IDs.
It is not cryptographically secure, don't use it to hash passwords or something!
*/
function
obfdeobf
(
$id
){
function
obfdeobf
(
$id
,
$dec
){
$salt
=
getObfuscationSalt
()
&
0xFFFFFFFF
;
$id
=
$id
&
0xFFFFFFFF
;
for
(
$i
=
0
;
$i
<
16
;
$i
++
){
if
(
$dec
){
$id
=
$id
^
$salt
;
$salt
=
((
$salt
>>
1
)
&
0xFFFFFFFF
)
|
((
$salt
&
0x00000001
)
<<
31
);
$id
=
((
0x0000FFFF
&
$id
)
<<
16
)
|
((
0xFFFF0000
&
$id
)
>>
16
);
$id
=
((
$id
>>
1
)
&
0xFFFFFFFF
)
|
((
$id
&
0x00000001
)
<<
31
);
$id
=
((
$id
&
0xAAAAAAAA
)
>>
1
)
|
(
$id
&
0x55555555
)
<<
1
;
$id
=
((
$id
&
0x0000FFFF
)
<<
16
)
|
((
$id
&
0xFFFF0000
)
>>
16
);
return
$id
;
}
else
{
$id
=
((
$id
&
0x0000FFFF
)
<<
16
)
|
((
$id
&
0xFFFF0000
)
>>
16
);
$id
=
((
$id
&
0xAAAAAAAA
)
>>
1
)
|
(
$id
&
0x55555555
)
<<
1
;
return
$id
^
$salt
;
}
return
$id
;
}
function
obfuscateId
(
$id
){
return
str_pad
(
base_convert
(
obfdeobf
(
$id
+
1
),
10
,
36
),
7
,
0
,
STR_PAD_LEFT
);
return
str_pad
(
base_convert
(
obfdeobf
(
$id
+
1
,
false
),
10
,
36
),
7
,
0
,
STR_PAD_LEFT
);
}
function
deobfuscateId
(
$id
){
return
obfdeobf
(
base_convert
(
$id
,
36
,
10
))
-
1
;
return
obfdeobf
(
base_convert
(
$id
,
36
,
10
)
,
true
)
-
1
;
}
//IMPORTANT: DO NOT ADD ANYTHING BELOW THE PHP CLOSING TAG, NOT EVEN EMPTY LINES!
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment