|
64 | 64 | ### Supported Algorithms
|
65 | 65 | The `Digest` class supports the following algorithms:
|
66 | 66 |
|
67 |
| -* `.MD2` |
68 |
| -* `.MD4` |
69 |
| -* `.MD5` |
70 |
| -* `.SHA1` |
71 |
| -* `.SHA224` |
72 |
| -* `.SHA256` |
73 |
| -* `.SHA384` |
74 |
| -* `.SHA512` |
| 67 | +* `.md2` |
| 68 | +* `.md4` |
| 69 | +* `.md5` |
| 70 | +* `.sha1` |
| 71 | +* `.sha224` |
| 72 | +* `.sha256` |
| 73 | +* `.sha384` |
| 74 | +* `.sha512` |
75 | 75 |
|
76 | 76 | Using `HMAC`
|
77 | 77 | ------------
|
78 | 78 |
|
79 | 79 | Calculating a keyed-Hash Message Authentication Code (HMAC) is very similar to calculating a message digest, except that the initialization routine now takes a key as well as an algorithm parameter.
|
80 | 80 |
|
81 | 81 | ```swift
|
82 |
| -var keys5 = arrayFromHexString("0102030405060708090a0b0c0d0e0f10111213141516171819") |
| 82 | +var keys5 = arrayFrom(hexString: "0102030405060708090a0b0c0d0e0f10111213141516171819") |
83 | 83 | var datas5 : [UInt8] = Array(count:50, repeatedValue:0xcd)
|
84 |
| -var expecteds5 = arrayFromHexString("4c9007f4026250c6bc8414f9bf50c86c2d7235da") |
85 |
| -var hmacs5 = HMAC(algorithm:.SHA1, key:keys5).update(datas5)?.final() |
| 84 | +var expecteds5 = arrayFrom(hexString: "4c9007f4026250c6bc8414f9bf50c86c2d7235da") |
| 85 | +var hmacs5 = HMAC(algorithm:.sha1, key:keys5).update(datas5)?.final() |
86 | 86 |
|
87 | 87 | // RFC2202 says this should be 4c9007f4026250c6bc8414f9bf50c86c2d7235da
|
88 |
| -let expectedRFC2202 = arrayFromHexString("4c9007f4026250c6bc8414f9bf50c86c2d7235da") |
| 88 | +let expectedRFC2202 = arrayFrom(hexString: "4c9007f4026250c6bc8414f9bf50c86c2d7235da") |
89 | 89 | assert(hmacs5! == expectedRFC2202)
|
90 | 90 | ```
|
91 | 91 | ### Supported Algorithms
|
92 |
| -* SHA1 |
93 |
| -* MD5 |
94 |
| -* SHA224 |
95 |
| -* SHA256 |
96 |
| -* SHA384 |
97 |
| -* SHA512 |
| 92 | +* `.md5` |
| 93 | +* `.sha1` |
| 94 | +* `.sha224` |
| 95 | +* `.sha256` |
| 96 | +* `.sha384` |
| 97 | +* `.sha512` |
98 | 98 |
|
99 | 99 | ## Using `Cryptor`
|
100 | 100 |
|
101 | 101 | ```swift
|
102 |
| -var key = arrayFromHexString("2b7e151628aed2a6abf7158809cf4f3c") |
| 102 | +var key = arrayFrom(hexString: "2b7e151628aed2a6abf7158809cf4f3c") |
103 | 103 | var plainText = "The quick brown fox jumps over the lazy dog. The fox has more or less had it at this point."
|
104 | 104 |
|
105 | 105 | var cryptor = Cryptor(operation:.encrypt, algorithm:.aes, options:.PKCS7Padding, key:key, iv:Array<UInt8>())
|
@@ -187,14 +187,14 @@ The following example derives a 20-byte key:
|
187 | 187 | ```swift
|
188 | 188 | let keys6 = PBKDF.deriveKey("password", salt: "salt", prf: .SHA1, rounds: 1, derivedKeyLength: 20)
|
189 | 189 | // RFC 6070 - Should derive 0c60c80f961f0e71f3a9b524af6012062fe037a6
|
190 |
| -let expectedRFC6070 = arrayFromHexString("0c60c80f961f0e71f3a9b524af6012062fe037a6") |
| 190 | +let expectedRFC6070 = arrayFrom(hexString: "0c60c80f961f0e71f3a9b524af6012062fe037a6") |
191 | 191 | assert(keys6 == expectedRFC6070)
|
192 | 192 | ```
|
193 | 193 | ### Supported Pseudo-Random Functions
|
194 |
| -* `.SHA1` |
195 |
| -* `.SHA224` |
196 |
| -* `.SHA256` |
197 |
| -* `.SHA384` |
198 |
| -* `.SHA512` |
| 194 | +* `.sha1` |
| 195 | +* `.sha224` |
| 196 | +* `.sha256` |
| 197 | +* `.sha384` |
| 198 | +* `.sha512` |
199 | 199 |
|
200 | 200 |
|
0 commit comments