Family Day update

This commit is contained in:
Ingy döt Net 2020-02-17 23:21:07 -08:00
parent aac6731f2c
commit 9ad63ea473
2442 changed files with 39761 additions and 8255 deletions

8
Task/MD5/Haxe/md5.haxe Normal file
View file

@ -0,0 +1,8 @@
import haxe.crypto.Md5;
class Main {
static function main() {
var md5 = Md5.encode("The quick brown fox jumped over the lazy dog's back");
Sys.println(md5);
}
}

3
Task/MD5/Ol/md5-1.ol Normal file
View file

@ -0,0 +1,3 @@
(import (otus ffi))
(define libcrypto (load-dynamic-library "libcrypto.so.1.0.0"))
(define MD5 (libcrypto type-vptr "MD5" type-string fft-unsigned-long type-string))

18
Task/MD5/Ol/md5-2.ol Normal file
View file

@ -0,0 +1,18 @@
(define (test str)
(define md5 "----------------")
(MD5 str (string-length str) md5)
(for-each display (list "\"" str "\": "))
(for-each (lambda (c)
(define hex "0123456789abcdef")
(display (string (ref hex (>> c 4))))
(display (string (ref hex (band c #x0F)))))
(string->list md5))
(print))
(test "")
(test "a")
(test "abc")
(test "message digest")
(test "abcdefghijklmnopqrstuvwxyz")
(test "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
(test "12345678901234567890123456789012345678901234567890123456789012345678901234567890")

View file

@ -0,0 +1,25 @@
Imports System.Security.Cryptography
Imports System.Text
Module MD5hash
Sub Main(args As String())
Console.WriteLine(GetMD5("Visual Basic .Net"))
End Sub
Private Function GetMD5(plainText As String) As String
Dim hash As String = ""
Using hashObject As MD5 = MD5.Create()
Dim ptBytes As Byte() = hashObject.ComputeHash(Encoding.UTF8.GetBytes(plainText))
Dim hashBuilder As New StringBuilder
For i As Integer = 0 To ptBytes.Length - 1
hashBuilder.Append(ptBytes(i).ToString("X2"))
Next
hash = hashBuilder.ToString
End Using
Return hash
End Function
End Module