Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
64f01804
Commit
64f01804
authored
Aug 30, 2006
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*Really* fix base 64 encoding
parent
f8343052
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
include/vlc_url.h
include/vlc_url.h
+4
-3
src/test/url.c
src/test/url.c
+3
-3
No files found.
include/vlc_url.h
View file @
64f01804
...
...
@@ -222,6 +222,7 @@ static inline char *vlc_b64_encode( const char *src )
static
const
char
b64
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
size_t
len
=
strlen
(
src
);
const
uint8_t
*
in
=
(
const
uint8_t
*
)
src
;
char
*
ret
;
char
*
dst
=
(
char
*
)
malloc
(
(
len
+
4
)
*
4
/
3
);
...
...
@@ -233,17 +234,17 @@ static inline char *vlc_b64_encode( const char *src )
while
(
len
>
0
)
{
/* pops (up to) 3 bytes of input, push 4 bytes */
uint32_t
v
=
*
src
++
<<
24
;
// 1/3
uint32_t
v
=
*
in
++
<<
24
;
// 1/3
*
dst
++
=
b64
[
v
>>
26
];
// 1/4
v
=
v
<<
6
;
if
(
len
>=
2
)
v
|=
*
src
++
<<
16
;
// 2/3
v
|=
*
in
++
<<
22
;
// 2/3
*
dst
++
=
b64
[
v
>>
26
];
// 2/4
v
=
v
<<
6
;
if
(
len
>=
3
)
v
|=
*
src
++
<<
8
;
// 3/3
v
|=
*
in
++
<<
20
;
// 3/3
*
dst
++
=
(
len
>=
2
)
?
b64
[
v
>>
26
]
:
'='
;
// 3/4
v
=
v
<<
6
;
...
...
src/test/url.c
View file @
64f01804
...
...
@@ -82,9 +82,9 @@ int main (void)
/* Base 64 tests */
test_b64
(
""
,
""
);
test_b64
(
"d"
,
"ZA=="
);
test_b64
(
"ab"
,
"Y
QG
="
);
test_b64
(
"abc"
,
"Y
QGI
"
);
test_b64
(
"abcd"
,
"Y
QGI
ZA=="
);
test_b64
(
"ab"
,
"Y
WI
="
);
test_b64
(
"abc"
,
"Y
WJj
"
);
test_b64
(
"abcd"
,
"Y
WJj
ZA=="
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment