Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
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
Container 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
Verlässliche Systemsoftware
projects
osv
Commits
8b3abd91
Commit
8b3abd91
authored
11 years ago
by
Guy Zana
Browse files
Options
Downloads
Patches
Plain Diff
cli: add md5sum util, used for validating downloads
parent
0c34d7f1
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bootfs.manifest
+1
-0
1 addition, 0 deletions
bootfs.manifest
console/cli.js
+2
-0
2 additions, 0 deletions
console/cli.js
console/md5sum.js
+41
-0
41 additions, 0 deletions
console/md5sum.js
java/cloudius/com/cloudius/util/MD5.java
+46
-0
46 additions, 0 deletions
java/cloudius/com/cloudius/util/MD5.java
with
90 additions
and
0 deletions
bootfs.manifest
+
1
−
0
View file @
8b3abd91
...
...
@@ -115,4 +115,5 @@
/console/ifconfig.js: ../../console/ifconfig.js
/console/cli.js: ../../console/cli.js
/console/init.js: ../../console/init.js
/console/md5sum.js: ../../console/md5sum.js
/&/etc/hosts: ../../static/&
This diff is collapsed.
Click to expand it.
console/cli.js
+
2
−
0
View file @
8b3abd91
...
...
@@ -15,6 +15,7 @@ load("/console/tests.js");
load
(
"
/console/run.js
"
);
load
(
"
/console/ifconfig.js
"
);
load
(
"
/console/arp.js
"
);
load
(
"
/console/md5sum.js
"
);
load
(
"
/console/route.js
"
);
// Commands
...
...
@@ -29,6 +30,7 @@ _commands["run"] = run_cmd;
_commands
[
"
ifconfig
"
]
=
ifconfig_cmd
;
_commands
[
"
arp
"
]
=
arp_cmd
;
_commands
[
"
route
"
]
=
route_cmd
;
_commands
[
"
md5sum
"
]
=
md5sum_cmd
;
// Create interface to networking functions
var
networking_interface
=
new
Networking
();
...
...
This diff is collapsed.
Click to expand it.
console/md5sum.js
0 → 100644
+
41
−
0
View file @
8b3abd91
var
md5sum_cmd
=
{
init
:
function
()
{
this
.
_md5
=
new
MD5
();
},
md5sum
:
function
(
filename
)
{
var
digest
=
this
.
_md5
.
md5
(
cd
.
pwd
()
+
"
/
"
+
filename
);
return
(
digest
)
},
invoke
:
function
(
inp
)
{
if
(
inp
.
length
<
2
)
{
this
.
help
();
return
;
}
var
digest
=
this
.
md5sum
(
inp
[
1
]);
print
(
digest
+
"
"
+
inp
[
1
]);
return
(
digest
);
},
tab
:
function
(
inp
)
{
if
(
inp
.
length
>
2
)
{
return
([]);
}
if
((
inp
.
length
==
2
)
&&
(
completed_word
()))
{
return
([]);
}
return
(
ls
.
ls
());
},
help
:
function
()
{
print
(
"
md5sum: calculate md5 of file
"
);
print
(
"
usage: md5sum <filename>
"
);
}
}
This diff is collapsed.
Click to expand it.
java/cloudius/com/cloudius/util/MD5.java
0 → 100644
+
46
−
0
View file @
8b3abd91
package
com.cloudius.util
;
import
java.io.FileInputStream
;
import
java.security.MessageDigest
;
public
class
MD5
{
public
static
String
toHex
(
byte
[]
bytes
)
{
final
char
[]
hexArray
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
char
[]
hexChars
=
new
char
[
bytes
.
length
*
2
];
int
v
;
for
(
int
j
=
0
;
j
<
bytes
.
length
;
j
++
)
{
v
=
bytes
[
j
]
&
0xFF
;
hexChars
[
j
*
2
]
=
hexArray
[
v
>>>
4
];
hexChars
[
j
*
2
+
1
]
=
hexArray
[
v
&
0x0F
];
}
return
new
String
(
hexChars
);
}
public
static
String
md5
(
String
filename
)
{
try
{
FileInputStream
fi
=
new
FileInputStream
(
filename
);
MessageDigest
m
=
MessageDigest
.
getInstance
(
"MD5"
);
m
.
reset
();
int
chunk_sz
=
0x1000
;
byte
bytes
[]
=
new
byte
[
chunk_sz
];
int
len
=
chunk_sz
;
while
(
len
==
chunk_sz
)
{
len
=
fi
.
read
(
bytes
);
m
.
update
(
bytes
,
0
,
len
);
}
fi
.
close
();
// Calculate digest
byte
[]
digest
=
m
.
digest
();
return
(
toHex
(
digest
));
}
catch
(
Exception
ex
){
System
.
out
.
println
(
"md5() error:"
);
ex
.
printStackTrace
();
return
(
null
);
}
}
}
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