Skip to content

Commit

Permalink
Merge pull request #7 from oxinabox/ox/seven
Browse files Browse the repository at this point in the history
julia 0.7
  • Loading branch information
oxinabox authored Sep 24, 2018
2 parents 1770ace + 730c823 commit c4ba85d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ os:
- linux
- osx
julia:
- 0.6
- 0.7
- 1.0
- nightly
notifications:
email: false
Expand Down
3 changes: 1 addition & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
julia 0.6
SHA 0.5.3
julia 0.7
52 changes: 24 additions & 28 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

## uncomment the following lines to allow failures on nightly julia
## (tests will run but not make your overall status red)
#matrix:
# allow_failures:
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
- julia_version: 0.7
- julia_version: 1
- julia_version: nightly

platform:
- x86 # 32-bit
- x64 # 64-bit

# # Uncomment the following lines to allow failures on nightly julia
# # (tests will run but not make your overall status red)
# matrix:
# allow_failures:
# - julia_version: nightly

branches:
only:
Expand All @@ -24,24 +26,18 @@ notifications:
on_build_status_changed: false

install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# If there's a newer build queued for the same PR, cancel this one
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
throw "There are newer queued builds for this pull request, failing early." }
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$env:JULIA_URL,
"C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))

build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo();
Pkg.clone(pwd(), \"MD5\"); Pkg.build(\"MD5\")"
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- C:\projects\julia\bin\julia -e "Pkg.test(\"MD5\")"
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

# # Uncomment to support code coverage upload. Should only be enabled for packages
# # which would have coverage gaps without running on Windows
# on_success:
# - echo "%JL_CODECOV_SCRIPT%"
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
7 changes: 3 additions & 4 deletions src/MD5.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module MD5

# package code goes here

using SHA
using SHA: lrot, SHA_CTX
Expand All @@ -14,23 +13,23 @@ include("core.jl")


# Our basic function is to process arrays of bytes
function md5(data::T) where T<:Union{Array{UInt8,1},NTuple{N,UInt8} where N}
function md5(data::T) where T<:Union{AbstractVector{UInt8}, NTuple{N,UInt8} where N}
ctx = MD5_CTX()
update!(ctx, data)
return digest!(ctx)
end


# AbstractStrings are a pretty handy thing to be able to crunch through
md5(str::AbstractString) = md5(Vector{UInt8}(str))
md5(str::AbstractString) = md5(codeunits(str))

# Convenience function for IO devices, allows for things like:
# open("test.txt") do f
# sha256(f)
# done
function md5(io::IO, chunk_size=4*1024)
ctx = MD5_CTX()
buff = Vector{UInt8}(chunk_size)
buff = Vector{UInt8}(undef, chunk_size)
while !eof(io)
num_read = readbytes!(io, buff)
update!(ctx, buff[1:num_read])
Expand Down
9 changes: 7 additions & 2 deletions test/nettle.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import Nettle
# redundant imports, so this file can be run standalone
using Base.Test
using Test
import MD5
using Random


import Nettle


function test_equal_state(md5_value::MD5.MD5_CTX,nettle_value::Nettle.Hasher)
@test nettle_value.state[1:16] ==
Expand Down Expand Up @@ -33,3 +37,4 @@ end
end
end
end

14 changes: 7 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MD5
using Base.Test
using Test

@testset "String Tests" begin
# From the reference https://tools.ietf.org/html/rfc1321 (final page)
Expand All @@ -14,18 +14,18 @@ using Base.Test
end

@testset "Different forms of input data consistent" begin
for len in [0,1,10,100,1000]
bytearray = rand(UInt8, len)
str = String(bytearray)
stream = IOBuffer(bytearray)
@test md5(bytearray) == md5(str)
for len in [0,1,10, 100,1000]
bytes = rand(UInt8, len)
str = String(copy(bytes)) # String will take ownership and empty it's array inputs
stream = IOBuffer(bytes)
@test md5(bytes) == md5(str)
@test md5(stream) == md5(str)
end
end

@testset "misc" begin
@test MD5.digestlen(MD5.MD5_CTX) == length(md5(""))
@test contains(sprint(show, MD5.MD5_CTX()), "MD5")
@test occursin("MD5", sprint(show, MD5.MD5_CTX()))
end

include("nettle.jl")

0 comments on commit c4ba85d

Please sign in to comment.