Created
March 2, 2018 10:59
-
-
Save mczachurski/37c0294e25d9081df84edd58da710c05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func generateHash(salt: String) throws -> String { | |
let stringWithSalt = salt + self | |
guard let stringArray = stringWithSalt.digest(.sha256)?.encode(.base64) else { | |
throw GeneratePasswordError() | |
} | |
guard let stringHash = String(data: Data(bytes: stringArray, count: stringArray.count), encoding: .utf8) else { | |
throw GeneratePasswordError() | |
} | |
return stringHash | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment