Skip to content

Commit 76a330d

Browse files
update code example to be OWASP compliant
1 parent 723ca8e commit 76a330d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

2-
func encrypt() {
2+
func hash() {
33
// ...
44

5-
// BAD: Using insufficient (that is, < 120,000) hash iterations keys for encryption
5+
// BAD: Using insufficient (that is, < 120,000) iterations for password hashing
66
_ = try PKCS5.PBKDF1(password: getRandomArray(), salt: getRandomArray(), iterations: 90000, keyLength: 0)
77
_ = try PKCS5.PBKDF2(password: getRandomArray(), salt: getRandomArray(), iterations: 90000, keyLength: 0)
88

9-
// GOOD: Using sufficient (that is, >= 120,000) hash iterations keys for encryption
9+
// GOOD: Using sufficient (that is, >= 120,000) iterations for password hashing
1010
_ = try PKCS5.PBKDF1(password: getRandomArray(), salt: getRandomArray(), iterations: 120120, keyLength: 0)
11-
_ = try PKCS5.PBKDF2(password: getRandomArray(), salt: getRandomArray(), iterations: 120120, keyLength: 0)
11+
_ = try PKCS5.PBKDF2(password: getRandomArray(), salt: getRandomArray(), iterations: 310000, keyLength: 0)
1212

1313
// ...
1414
}

0 commit comments

Comments
 (0)