Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4 from vapor/swift4
Browse files Browse the repository at this point in the history
Swift4
  • Loading branch information
loganwright authored Aug 4, 2017
2 parents c14e6b9 + aa7c0f2 commit 3ee4aca
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 9 deletions.
43 changes: 43 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"object": {
"pins": [
{
"package": "Bits",
"repositoryURL": "https://github.com/vapor/bits.git",
"state": {
"branch": null,
"revision": "c32f5e6ae2007dccd21a92b7e33eba842dd80d2f",
"version": "1.1.0"
}
},
{
"package": "Core",
"repositoryURL": "https://github.com/vapor/core.git",
"state": {
"branch": null,
"revision": "1b593cd335b465b92cc530b5125f4712cc2827cc",
"version": "2.1.1"
}
},
{
"package": "Debugging",
"repositoryURL": "https://github.com/vapor/debugging.git",
"state": {
"branch": null,
"revision": "49c5e8f0a7cb5456a8f7c72c6cd9f1553e5885a8",
"version": "1.1.0"
}
},
{
"package": "Random",
"repositoryURL": "https://github.com/vapor/random.git",
"state": {
"branch": null,
"revision": "d7c4397d125caba795d14d956efacfe2a27a63d0",
"version": "1.2.0"
}
}
]
},
"version": 1
}
18 changes: 18 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// swift-tools-version:4.0

import PackageDescription

let package = Package(
name: "BCrypt",
products: [
.library(name: "BCrypt", targets: ["BCrypt"]),
],
dependencies: [
// Module for generating random bytes and numbers.
.package(url: "https://github.com/vapor/random.git", .upToNextMajor(from: "1.2.0")),
],
targets: [
.target(name: "BCrypt", dependencies: ["Random"]),
.testTarget(name: "BCryptTests", dependencies: ["BCrypt"]),
]
)
27 changes: 19 additions & 8 deletions Sources/BCrypt/Hash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,25 @@ public final class Hash {

j = 0
for i in 0..<clen {
result[j] = UInt8(truncatingBitPattern: (cdata[i] >> 24) & 0xff)
j += 1
result[j] = UInt8(truncatingBitPattern: (cdata[i] >> 16) & 0xff)
j += 1
result[j] = UInt8(truncatingBitPattern: (cdata[i] >> 8) & 0xff)
j += 1
result[j] = UInt8(truncatingBitPattern: cdata[i] & 0xff)
j += 1
#if swift(>=4)
result[j] = UInt8(truncatingIfNeeded: (cdata[i] >> 24) & 0xff)
j += 1
result[j] = UInt8(truncatingIfNeeded: (cdata[i] >> 16) & 0xff)
j += 1
result[j] = UInt8(truncatingIfNeeded: (cdata[i] >> 8) & 0xff)
j += 1
result[j] = UInt8(truncatingIfNeeded: cdata[i] & 0xff)
j += 1
#else
result[j] = UInt8(truncatingBitPattern: (cdata[i] >> 24) & 0xff)
j += 1
result[j] = UInt8(truncatingBitPattern: (cdata[i] >> 16) & 0xff)
j += 1
result[j] = UInt8(truncatingBitPattern: (cdata[i] >> 8) & 0xff)
j += 1
result[j] = UInt8(truncatingBitPattern: cdata[i] & 0xff)
j += 1
#endif
}

let digest = result[0..<23].array
Expand Down
15 changes: 14 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
dependencies:
override:
- eval "$(curl -sL https://apt.vapor.sh)"
- sudo apt-get install swift
- sudo chmod -R a+rx /usr/
test:
override:
- eval "$(curl -sL swift.vapor.sh/ci-3.1)"
- swift build
- swift build -c release
- swift test
- sudo apt-get remove swift
- sudo apt-get install swift-beta
- swift build
- swift build -c release
- swift test

0 comments on commit 3ee4aca

Please sign in to comment.