Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
popwarfour committed Jul 20, 2017
1 parent 4f2fbed commit b9de260
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Sources/JWT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public enum Algorithm: CustomStringConvertible {

func signHS(_ key: Data, variant: CryptoSwift.HMAC.Variant) -> String {
let messageData = message.data(using: String.Encoding.utf8, allowLossyConversion: false)!

let mac = HMAC(key: key.bytes, variant: variant)
let result: [UInt8]
do {
Expand All @@ -58,7 +59,7 @@ public enum Algorithm: CustomStringConvertible {

func signRS(_ key: Data, digestType: Signature.DigestType) throws -> String {

let keyString = String.init(data: key, encoding: .utf8)
let keyString = message.data(using: String.Encoding.utf8, allowLossyConversion: false)!
let privateKey = try PrivateKey(pemEncoded: keyString)

let clear = try ClearMessage(string: message, using: .utf8)
Expand All @@ -85,7 +86,7 @@ public enum Algorithm: CustomStringConvertible {

case .rs256(let key):
return try signRS(privateKey, digestType: .sha256)

case .rs512(let key):
return try signRS(privateKey, digestType: .sha512)

Expand Down

0 comments on commit b9de260

Please sign in to comment.