Giter Site home page Giter Site logo

argon2swift's Introduction

Argon2Swift

Argon2Swift Swift License: MIT

Swift bindings for the reference C implementation of Argon2, the winner of the Password Hash Competition.

Installation (Cocoapods)

Argon2Swift can be installed via Cocoapods by adding the following to your Podfile:

pod Argon2Swift

Installation (SPM)

Argon2Swift can be installed via SPM (Swift Package Manger) by adding the following to your depencencies:

.package(url: "https://github.com/tmthecoder/Argon2Swift.git", .branch("main"))

Usage

High-level hashing and verification (for direct hashing & verification of byte arrays, check the example)

import Argon2Swift

// Create a password and a salt
let password = "password"
let s = Salt.newSalt()
//Hash with pre-set params (iterations: 32, memory: 256, parallelism: 2, length: 32, type: Argon2Type.i, version: Argon2Version.V13)
let result = try! Argon2Swift.hashPasswordString(password: password, salt: s)

//Raw hash values available as int list, base 64 string, and hex string
let hashData = result.hashData()
let base64Hash = result.base64String()
let hexHash = result.hexString()

//Encoded hash values available as int list and encoded string
let encodedData = result.encodedData()
let encodedString = result.encodedString()

//Verify password (returns true/false), uses default type (Argon2Type.i)
let verified = try! Argon2Swift.verifyHashString(password: password, hash: stringEncoded);

Features and bugs

Please file feature requests and bugs at the issue tracker.

Licensing

argon2swift's People

Contributors

batonpiotr avatar tmthecoder avatar vzsg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

argon2swift's Issues

Linux compatibility

Hello! Thank you for the fantastic library!

Unfortunately, the utilization of macOS-specific frameworks (specifically Security) prevents this library from being used on Linux for server environments, e.g. with Vapor APIs.

Is there any way this can be updated to be Linux-compatible?

Get Salt Data

Can you provide public method/variable for Salt data?

Insecure source code functions have been used in the binary

Hello!

We are using Argon2Swift in our iOS app. We got warning about using insecure API(s) from the penetration testing: The binary may contain the following insecure API calls: _printf, _memcpy, _strlen, _sscanf, _fopen, _strncpy.

Could you remove these from the library in your upcoming release or if it is required, could you let us know why it is required?

Broken tests on Linux

Current project layout is not compatible with Swift 5.3, opposed to the supported minimum version of toolchain specified in Package.swift.

I ran a build on Linux using Swift 5.3 and got the following error,

[Swift/build-linux-1]   ๐Ÿณ  docker create image=swift:5.3-focal platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Swift/build-linux-1]   ๐Ÿณ  docker run image=swift:5.3-focal platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Swift/build-linux-1]   ๐Ÿณ  docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root workdir=
[Swift/build-linux-1]   ๐Ÿณ  docker cp src=/Users/segabor/Workspace/Argon2Swift/. dst=/Users/segabor/Workspace/Argon2Swift
[Swift/build-linux-1]   ๐Ÿณ  docker exec cmd=[mkdir -p /Users/segabor/Workspace/Argon2Swift] user= workdir=
[Swift/build-linux-1] โญ  Run actions/checkout@v2
[Swift/build-linux-1]   โœ…  Success - actions/checkout@v2
[Swift/build-linux-1] โญ  Run Build
[Swift/build-linux-1]   ๐Ÿณ  docker exec cmd=[sh -e -c /var/run/act/workflow/1.sh] user= workdir=
| lsb_release -r
| /usr/bin/swiftc -print-target-info
| /usr/bin/swiftc -L /usr/lib/swift/pm/4_2 -lPackageDescription -Xlinker -rpath -Xlinker /usr/lib/swift/pm/4_2 -swift-version 5 -I /usr/lib/swift/pm/4_2 -package-description-version 5.3.0 /Users/segabor/Workspace/Argon2Swift/Package.swift -o /tmp/TemporaryDirectory.KqxwBl/argon2swift-manifest
| /tmp/TemporaryDirectory.KqxwBl/argon2swift-manifest -fileno 9
| Running resolver because the following dependencies were added: 'https://github.com/P-H-C/phc-winner-argon2.git'
| /usr/bin/swiftc -L /usr/lib/swift/pm/4_2 -lPackageDescription -Xlinker -rpath -Xlinker /usr/lib/swift/pm/4_2 -swift-version 5 -I /usr/lib/swift/pm/4_2 -package-description-version 5.3.0 /tmp/TemporaryFile.olQy3h.swift -o /tmp/TemporaryDirectory.NL0Nzj/argon2swift-manifest
| /tmp/TemporaryDirectory.NL0Nzj/argon2swift-manifest -fileno 10
| Fetching https://github.com/P-H-C/phc-winner-argon2.git
| git clone --mirror https://github.com/P-H-C/phc-winner-argon2.git /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c rev-parse --is-bare-repository
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c tag -l
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c rev-parse --verify '16d3df698db2486dde480b09a732bf9bf48599f9^{commit}'
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c rev-parse --verify '16d3df698db2486dde480b09a732bf9bf48599f9^{tree}'
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c ls-tree e3df7f06a95990497728d5240e6796104ac4f7bb
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c cat-file -p d3d9c83c63a92d579d32b531b19d569180655f48
| /usr/bin/swiftc -L /usr/lib/swift/pm/4_2 -lPackageDescription -Xlinker -rpath -Xlinker /usr/lib/swift/pm/4_2 -swift-version 5 -I /usr/lib/swift/pm/4_2 -package-description-version 5.3.0 /tmp/TemporaryFile.PBwMnj.swift -o /tmp/TemporaryDirectory.wPtQLh/phc-winner-argon2-manifest
| /tmp/TemporaryDirectory.wPtQLh/phc-winner-argon2-manifest -fileno 13
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c rev-parse --verify 'master^{commit}'
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c rev-parse --verify 'f57e61e19229e23c4445b85494dbf7c07de721cb^{tree}'
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c ls-tree ac3dc753ff75ce5a0f243cba1d94582bafe09409
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c rev-parse --is-bare-repository
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c rev-parse --is-bare-repository
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c tag -l
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c rev-parse --verify 'master^{commit}'
| git -C /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c rev-parse --is-bare-repository
| Cloning https://github.com/P-H-C/phc-winner-argon2.git
| git clone --shared /Users/segabor/Workspace/Argon2Swift/.build/repositories/phc-winner-argon2-49249c9c /Users/segabor/Workspace/Argon2Swift/.build/checkouts/phc-winner-argon2
| git -C /Users/segabor/Workspace/Argon2Swift/.build/checkouts/phc-winner-argon2 rev-parse --is-bare-repository
| Resolving https://github.com/P-H-C/phc-winner-argon2.git at master
| git -C /Users/segabor/Workspace/Argon2Swift/.build/checkouts/phc-winner-argon2 checkout -f 16d3df698db2486dde480b09a732bf9bf48599f9
| git -C /Users/segabor/Workspace/Argon2Swift/.build/checkouts/phc-winner-argon2 submodule update --init --recursive
| git -C /Users/segabor/Workspace/Argon2Swift/.build/checkouts/phc-winner-argon2 clean -ffdx
| /usr/bin/swiftc -L /usr/lib/swift/pm/4_2 -lPackageDescription -Xlinker -rpath -Xlinker /usr/lib/swift/pm/4_2 -swift-version 5 -I /usr/lib/swift/pm/4_2 -package-description-version 5.3.0 /Users/segabor/Workspace/Argon2Swift/.build/checkouts/phc-winner-argon2/Package.swift -o /tmp/TemporaryDirectory.y4xCTk/phc-winner-argon2-manifest
| /tmp/TemporaryDirectory.y4xCTk/phc-winner-argon2-manifest -fileno 12
| error: missing LinuxMain.swift file in the Tests directory
[Swift/build-linux-1]   โŒ  Failure - Build
[Swift/build-linux-1] exit with `FAILURE`: 1

It indicated the lack of LinuxMain.swift file in Tests folder which is no longer required for newer Swift toolchains.

I suggest to bump the minimum supported version to 5.4.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.