Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
e5fd792f
Commit
e5fd792f
authored
Mar 03, 2016
by
Marcel Stör
Browse files
Merge pull request #1106 from TerryE/dev-rm-base64-lua
Deleted two obsolete Lua base64 examples as per #475
parents
cfe35805
6fcd554e
Changes
2
Hide whitespace changes
Inline
Side-by-side
lua_modules/base64/base64.lua
deleted
100644 → 0
View file @
cfe35805
-- Lua 5.1+ base64 v3.0 (c) 2009 by Alex Kloss <alexthkloss@web.de>
-- licensed under the terms of the LGPL2
local
moduleName
=
...
local
M
=
{}
_G
[
moduleName
]
=
M
-- character table string
local
b
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
-- encoding
function
M
.
enc
(
data
)
return
((
data
:
gsub
(
'.'
,
function
(
x
)
local
r
,
b
=
''
,
x
:
byte
()
for
i
=
8
,
1
,
-
1
do
r
=
r
..
(
b
%
2
^
i
-
b
%
2
^
(
i
-
1
)
>
0
and
'1'
or
'0'
)
end
return
r
;
end
)
..
'0000'
):
gsub
(
'%d%d%d?%d?%d?%d?'
,
function
(
x
)
if
(
#
x
<
6
)
then
return
''
end
local
c
=
0
for
i
=
1
,
6
do
c
=
c
+
(
x
:
sub
(
i
,
i
)
==
'1'
and
2
^
(
6
-
i
)
or
0
)
end
return
b
:
sub
(
c
+
1
,
c
+
1
)
end
)
..
({
''
,
'=='
,
'='
})[
#
data
%
3
+
1
])
end
-- decoding
function
M
.
dec
(
data
)
data
=
string.gsub
(
data
,
'[^'
..
b
..
'=]'
,
''
)
return
(
data
:
gsub
(
'.'
,
function
(
x
)
if
(
x
==
'='
)
then
return
''
end
local
r
,
f
=
''
,(
b
:
find
(
x
)
-
1
)
for
i
=
6
,
1
,
-
1
do
r
=
r
..
(
f
%
2
^
i
-
f
%
2
^
(
i
-
1
)
>
0
and
'1'
or
'0'
)
end
return
r
;
end
):
gsub
(
'%d%d%d?%d?%d?%d?%d?%d?'
,
function
(
x
)
if
(
#
x
~=
8
)
then
return
''
end
local
c
=
0
for
i
=
1
,
8
do
c
=
c
+
(
x
:
sub
(
i
,
i
)
==
'1'
and
2
^
(
7
-
i
)
or
0
)
end
return
string.char
(
c
)
end
))
end
return
M
lua_modules/base64/base64_v2.lua
deleted
100644 → 0
View file @
cfe35805
--this version actually works
local
tab
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
base64
=
{
enc
=
function
(
data
)
local
l
,
out
=
0
,
''
local
m
=
(
3
-
data
:
len
()
%
3
)
%
3
local
d
=
data
..
string.rep
(
'
\0
'
,
m
)
for
i
=
1
,
d
:
len
()
do
l
=
bit
.
lshift
(
l
,
8
)
l
=
l
+
d
:
byte
(
i
,
i
)
if
i
%
3
==
0
then
for
j
=
1
,
4
do
local
a
=
bit
.
rshift
(
l
,
18
)
+
1
out
=
out
..
tab
:
sub
(
a
,
a
)
l
=
bit
.
band
(
bit
.
lshift
(
l
,
6
),
0xFFFFFF
)
end
end
end
return
out
:
sub
(
1
,
-
1
-
m
)
..
string.rep
(
'='
,
m
)
end
,
dec
=
function
(
data
)
local
a
,
b
=
data
:
gsub
(
'='
,
'A'
)
local
out
=
''
local
l
=
0
for
i
=
1
,
a
:
len
()
do
l
=
l
+
tab
:
find
(
a
:
sub
(
i
,
i
))
-
1
if
i
%
4
==
0
then
out
=
out
..
string.char
(
bit
.
rshift
(
l
,
16
),
bit
.
band
(
bit
.
rshift
(
l
,
8
),
255
),
bit
.
band
(
l
,
255
))
l
=
0
end
l
=
bit
.
lshift
(
l
,
6
)
end
return
out
:
sub
(
1
,
-
b
-
1
)
end
}
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