September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,2 @@
import crypto
let hash = sha1 bytes('Ars longa, vita brevis', encoding:'ascii')

View file

@ -85,7 +85,7 @@ program sha1
allocate(character(m) :: name)
call get_command_argument(i, name)
call sha1hash(name, hash, dwStatus, filesize)
if (dwStatus*0 == 0) then
if (dwStatus == 0) then
do j = 1, SHA1LEN
write(*, "(Z2.2)", advance="NO") hash(j)
end do

View file

@ -0,0 +1,2 @@
$var = "Rosetta Code";
echo sha1($var);

View file

@ -1,8 +0,0 @@
words2hex=: '0123456789abcdef' {~ (8#16)&#:
words2hex sha1 text2bits 'Rosetta Code'
48c98f7e
5a6e736d
790ab740
dfc3f51a
61abe2b5

View file

@ -0,0 +1,12 @@
// version 1.0.6
import java.security.MessageDigest
fun main(args: Array<String>) {
val text = "Rosetta Code"
val bytes = text.toByteArray()
val md = MessageDigest.getInstance("SHA-1")
val digest = md.digest(bytes)
for (byte in digest) print("%02x".format(byte))
println()
}

View file

@ -16,7 +16,7 @@ sub sha1-pad(Blob $msg)
flat @padded.map({ :256[$^a,$^b,$^c,$^d] }), (bits +> 32)mod2³², (bits)mod2³²;
}
sub sha1-block(@H is rw, @M is copy)
sub sha1-block(@H, @M is copy)
{
@M.push: S(1, [+^] @M[$_ «-« <3 8 14 16>] ) for 16 .. 79;

15
Task/SHA-1/Zkl/sha-1.zkl Normal file
View file

@ -0,0 +1,15 @@
$ zkl // run the REPL
zkl: var MsgHash=Import("zklMsgHash")
MsgHash
zkl: MsgHash.SHA1("Rosetta Code")
48c98f7e5a6e736d790ab740dfc3f51a61abe2b5
zkl: var hash=MsgHash.SHA1("Rosetta Code",1,False) // hash once, return hash as bytes
Data(20)
zkl: hash.bytes()
L(72,201,143,126,90,110,115,109,121,10,183,64,223,195,245,26,97,171,226,181)
zkl: hash.bytes().apply("toString",16).concat()
48c98f7e5a6e736d79ab740dfc3f51a61abe2b5
zkl: MsgHash.SHA1("a"*1000,1000); // hash 1000 a's 1000 times
34aa973cd4c4daa4f61eeb2bdbad27316534016f