September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
17
Task/MD5/BaCon/md5.bacon
Normal file
17
Task/MD5/BaCon/md5.bacon
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
PRAGMA INCLUDE <stdio.h>
|
||||
PRAGMA INCLUDE <stdlib.h>
|
||||
PRAGMA INCLUDE <string.h>
|
||||
PRAGMA INCLUDE <openssl/md5.h>
|
||||
PRAGMA LDFLAGS -lcrypto -lm -w
|
||||
|
||||
DECLARE result TYPE unsigned char *
|
||||
DECLARE string TYPE const char *
|
||||
|
||||
string = "Rosetta code"
|
||||
strlenght = LEN(string)
|
||||
|
||||
result = MD5( string, strlenght , 0)
|
||||
|
||||
FOR i = 0 TO MD5_DIGEST_LENGTH-1
|
||||
PRINT result[i] FORMAT "%02x"
|
||||
NEXT
|
||||
|
|
@ -83,7 +83,7 @@ program md5
|
|||
allocate(character(m) :: name)
|
||||
call get_command_argument(i, name)
|
||||
call md5hash(name, hash, dwStatus, filesize)
|
||||
if (dwStatus*0 == 0) then
|
||||
if (dwStatus == 0) then
|
||||
do j = 1, MD5LEN
|
||||
write(*, "(Z2.2)", advance="NO") hash(j)
|
||||
end do
|
||||
|
|
|
|||
|
|
@ -1,28 +1,25 @@
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* Test MD5 digest computation
|
||||
*
|
||||
* @author Roedy Green
|
||||
* @version 1.0
|
||||
* @since 2004-06-07
|
||||
*/
|
||||
public final class MD5{
|
||||
public static void main(String[] args) throws UnsupportedEncodingException,
|
||||
NoSuchAlgorithmException{
|
||||
byte[] theTextToDigestAsBytes=
|
||||
"The quick brown fox jumped over the lazy dog's back"
|
||||
.getBytes("8859_1");
|
||||
MessageDigest md= MessageDigest.getInstance("MD5");
|
||||
md.update(theTextToDigestAsBytes);
|
||||
byte[] digest= md.digest();
|
||||
public class Digester {
|
||||
|
||||
// dump out the hash
|
||||
for(byte b: digest){
|
||||
System.out.printf("%02X", b & 0xff);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
System.out.println(hexDigest("Rosetta code", "MD5"));
|
||||
}
|
||||
|
||||
static String hexDigest(String str, String digestName) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance(digestName);
|
||||
byte[] digest = md.digest(str.getBytes(StandardCharsets.UTF_8));
|
||||
char[] hex = new char[digest.length * 2];
|
||||
for (int i = 0; i < digest.length; i++) {
|
||||
hex[2 * i] = "0123456789abcdef".charAt((digest[i] & 0xf0) >> 4);
|
||||
hex[2 * i + 1] = "0123456789abcdef".charAt(digest[i] & 0x0f);
|
||||
}
|
||||
return new String(hex);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
Task/MD5/Kotlin/md5.kotlin
Normal file
12
Task/MD5/Kotlin/md5.kotlin
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// version 1.0.6
|
||||
|
||||
import java.security.MessageDigest
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val text = "The quick brown fox jumped over the lazy dog's back"
|
||||
val bytes = text.toByteArray()
|
||||
val md = MessageDigest.getInstance("MD5")
|
||||
val digest = md.digest(bytes)
|
||||
for (byte in digest) print("%02x".format(byte))
|
||||
println()
|
||||
}
|
||||
2
Task/MD5/Zkl/md5.zkl
Normal file
2
Task/MD5/Zkl/md5.zkl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Utils.MD5.calc("message digest"); //-->"f96b697d7cb7938d525a2f31aaf161d0"
|
||||
Utils.MD5.calc("abcdefghijklmnopqrstuvwxyz"); //-->"c3fcd3d76192e4007dfb496cca67e13b"
|
||||
Loading…
Add table
Add a link
Reference in a new issue