Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,34 +0,0 @@
|
|||
with Ada.Text_IO;
|
||||
|
||||
with CryptAda.Pragmatics;
|
||||
with CryptAda.Digests.Message_Digests.SHA_256;
|
||||
with CryptAda.Digests.Hashes;
|
||||
with CryptAda.Utils.Format;
|
||||
|
||||
procedure RC_SHA_256 is
|
||||
use CryptAda.Pragmatics;
|
||||
use CryptAda.Digests.Message_Digests;
|
||||
use CryptAda.Digests;
|
||||
|
||||
function To_Byte_Array (Item : String) return Byte_Array is
|
||||
Result : Byte_Array (Item'Range);
|
||||
begin
|
||||
for I in Result'Range loop
|
||||
Result (I) := Byte (Character'Pos (Item (I)));
|
||||
end loop;
|
||||
return Result;
|
||||
end To_Byte_Array;
|
||||
|
||||
Text : constant String := "Rosetta code";
|
||||
Bytes : constant Byte_Array := To_Byte_Array (Text);
|
||||
Handle : constant Message_Digest_Handle := SHA_256.Get_Message_Digest_Handle;
|
||||
Pointer : constant Message_Digest_Ptr := Get_Message_Digest_Ptr (Handle);
|
||||
Hash : Hashes.Hash;
|
||||
begin
|
||||
Digest_Start (Pointer);
|
||||
Digest_Update (Pointer, Bytes);
|
||||
Digest_End (Pointer, Hash);
|
||||
|
||||
Ada.Text_IO.Put_Line
|
||||
("""" & Text & """: " & CryptAda.Utils.Format.To_Hex_String (Hashes.Get_Bytes (Hash)));
|
||||
end RC_SHA_256;
|
||||
|
|
@ -1 +0,0 @@
|
|||
(secure-hash 'sha256 "Rosetta code") ;; as string of hex digits
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
module sha256_mod
|
||||
use kernel32
|
||||
use advapi32
|
||||
implicit none
|
||||
integer, parameter :: SHA256LEN = 32
|
||||
contains
|
||||
subroutine sha256hash(name, hash, dwStatus, filesize)
|
||||
implicit none
|
||||
character(*) :: name
|
||||
integer, parameter :: BUFLEN = 32768
|
||||
integer(HANDLE) :: hFile, hProv, hHash
|
||||
integer(DWORD) :: dwStatus, nRead
|
||||
integer(BOOL) :: status
|
||||
integer(BYTE) :: buffer(BUFLEN)
|
||||
integer(BYTE) :: hash(SHA256LEN)
|
||||
integer(UINT64) :: filesize
|
||||
|
||||
dwStatus = 0
|
||||
filesize = 0
|
||||
hFile = CreateFile(trim(name) // char(0), GENERIC_READ, FILE_SHARE_READ, NULL, &
|
||||
OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL)
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE) then
|
||||
dwStatus = GetLastError()
|
||||
print *, "CreateFile failed."
|
||||
return
|
||||
end if
|
||||
|
||||
if (CryptAcquireContext(hProv, NULL, MS_ENH_RSA_AES_PROV, PROV_RSA_AES, &
|
||||
CRYPT_VERIFYCONTEXT) == FALSE) then
|
||||
|
||||
dwStatus = GetLastError()
|
||||
print *, "CryptAcquireContext failed.", dwStatus
|
||||
goto 3
|
||||
end if
|
||||
|
||||
if (CryptCreateHash(hProv, CALG_SHA_256, 0_ULONG_PTR, 0_DWORD, hHash) == FALSE) then
|
||||
|
||||
dwStatus = GetLastError()
|
||||
print *, "CryptCreateHash failed."
|
||||
go to 2
|
||||
end if
|
||||
|
||||
do
|
||||
status = ReadFile(hFile, loc(buffer), BUFLEN, nRead, NULL)
|
||||
if (status == FALSE .or. nRead == 0) exit
|
||||
filesize = filesize + nRead
|
||||
if (CryptHashData(hHash, buffer, nRead, 0) == FALSE) then
|
||||
dwStatus = GetLastError()
|
||||
print *, "CryptHashData failed."
|
||||
go to 1
|
||||
end if
|
||||
end do
|
||||
|
||||
if (status == FALSE) then
|
||||
dwStatus = GetLastError()
|
||||
print *, "ReadFile failed."
|
||||
go to 1
|
||||
end if
|
||||
|
||||
nRead = SHA256LEN
|
||||
if (CryptGetHashParam(hHash, HP_HASHVAL, hash, nRead, 0) == FALSE) then
|
||||
dwStatus = GetLastError()
|
||||
print *, "CryptGetHashParam failed."
|
||||
end if
|
||||
|
||||
1 status = CryptDestroyHash(hHash)
|
||||
2 status = CryptReleaseContext(hProv, 0)
|
||||
3 status = CloseHandle(hFile)
|
||||
end subroutine
|
||||
end module
|
||||
|
||||
program sha256
|
||||
use sha256_mod
|
||||
implicit none
|
||||
integer :: n, m, i, j
|
||||
character(:), allocatable :: name
|
||||
integer(DWORD) :: dwStatus
|
||||
integer(BYTE) :: hash(SHA256LEN)
|
||||
integer(UINT64) :: filesize
|
||||
|
||||
n = command_argument_count()
|
||||
do i = 1, n
|
||||
call get_command_argument(i, length=m)
|
||||
allocate(character(m) :: name)
|
||||
call get_command_argument(i, name)
|
||||
call sha256hash(name, hash, dwStatus, filesize)
|
||||
if (dwStatus == 0) then
|
||||
do j = 1, SHA256LEN
|
||||
write(*, "(Z2.2)", advance="NO") hash(j)
|
||||
end do
|
||||
write(*, "(' ',A,' (',G0,' bytes)')") name, filesize
|
||||
end if
|
||||
deallocate(name)
|
||||
end do
|
||||
end program
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
import haxe.crypto.Sha256;
|
||||
|
||||
class Main {
|
||||
static function main() {
|
||||
var sha256 = Sha256.encode("Rosetta code");
|
||||
Sys.println(sha256);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
Set-Content -Value "Rosetta code" -Path C:\Colors\blue.txt -NoNewline -Force
|
||||
Get-FileHash -Path C:\Colors\blue.txt -Algorithm SHA256
|
||||
|
|
@ -1 +0,0 @@
|
|||
checksum "Rosetta code" 'sha256
|
||||
Loading…
Add table
Add a link
Reference in a new issue