Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80852064
I2b2PasswordCryptor.java
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Sep 2, 22:33
Size
946 B
Mime Type
text/x-c
Expires
Wed, Sep 4, 22:33 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20442095
Attached To
R2664 SHRINE MedCo Fork
I2b2PasswordCryptor.java
View Options
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
public
final
class
I2b2PasswordCryptor
{
public
static
String
toHex
(
byte
[]
digest
)
{
final
StringBuffer
buf
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
digest
.
length
;
i
++)
{
buf
.
append
(
Integer
.
toHexString
((
int
)
digest
[
i
]
&
0x00FF
));
}
return
buf
.
toString
();
}
public
static
String
getHashedPassword
(
String
pass
)
throws
Exception
{
try
{
final
MessageDigest
md5
=
MessageDigest
.
getInstance
(
"MD5"
);
md5
.
update
(
pass
.
getBytes
());
return
toHex
(
md5
.
digest
());
}
catch
(
NoSuchAlgorithmException
e
)
{
System
.
err
.
println
(
"No such algorithm MD5!"
);
System
.
exit
(-
1
);
}
return
null
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
!=
1
)
{
System
.
err
.
println
(
"Usage: java I2b2PasswordCryptor <plaintext password>"
);
System
.
exit
(-
1
);
}
System
.
out
.
println
(
getHashedPassword
(
args
[
0
]));
}
}
Event Timeline
Log In to Comment