mirror of
https://github.com/github/codeql.git
synced 2026-04-24 16:25:15 +02:00
Swift: Add GOOD and BAD comments in the sensitive data hashing examples as well.
This commit is contained in:
@@ -3,8 +3,8 @@ func getContentsAndHash(url: URL) -> (Data, String)? {
|
||||
return nil
|
||||
}
|
||||
|
||||
let digest = Insecure.MD5.hash(data: data)
|
||||
let digest = Insecure.MD5.hash(data: data) // BAD: MD5 is not suitable for hashing sensitive data.
|
||||
let hash = digest.map { String(format: "%02hhx", $0) }.joined()
|
||||
|
||||
return (data, hash)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ func getContentsAndHash(url: URL) -> (Data, String)? {
|
||||
return nil
|
||||
}
|
||||
|
||||
let digest = SHA512.hash(data: data)
|
||||
let digest = SHA512.hash(data: data) // GOOD: SHA-512 is suitable for hashing sensitive data.
|
||||
let hash = digest.map { String(format: "%02hhx", $0) }.joined()
|
||||
|
||||
return (data, hash)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user