Overview
Comment: | OF{Data,String}+CryptoHashing: Rename methods
This makes it clearer that these return a string and not a hash object. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b5a74319e1c5a56f8f4a3c3611b4abb5 |
User & Date: | js on 2021-04-07 19:22:20 |
Other Links: | manifest | tags |
Context
2021-04-07
| ||
20:39 | Override -[compare:] with a more specific type check-in: 91a4c53bb1 user: js tags: trunk | |
19:22 | OF{Data,String}+CryptoHashing: Rename methods check-in: b5a74319e1 user: js tags: trunk | |
18:44 | Rename OFEnumerating to OFEnumeration check-in: 151e4642fe user: js tags: trunk | |
Changes
Modified src/OFData+CryptoHashing.h from [a5a229d49d] to [eadea66cdb].
︙ | ︙ | |||
27 28 29 30 31 32 33 | } #endif @interface OFData (CryptoHashing) /** * @brief The MD5 hash of the data as a string. */ | | | | | | | | | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | } #endif @interface OFData (CryptoHashing) /** * @brief The MD5 hash of the data as a string. */ @property (readonly, nonatomic) OFString *stringByMD5Hashing; /** * @brief The RIPEMD-160 hash of the data as a string. */ @property (readonly, nonatomic) OFString *stringByRIPEMD160Hashing; /** * @brief The SHA-1 hash of the data as a string. */ @property (readonly, nonatomic) OFString *stringBySHA1Hashing; /** * @brief The SHA-224 hash of the data as a string. */ @property (readonly, nonatomic) OFString *stringBySHA224Hashing; /** * @brief The SHA-256 hash of the data as a string. */ @property (readonly, nonatomic) OFString *stringBySHA256Hashing; /** * @brief The SHA-384 hash of the data as a string. */ @property (readonly, nonatomic) OFString *stringBySHA384Hashing; /** * @brief The SHA-512 hash of the data as a string. */ @property (readonly, nonatomic) OFString *stringBySHA512Hashing; @end OF_ASSUME_NONNULL_END |
Modified src/OFData+CryptoHashing.m from [7bd2a07f00] to [9f6c94ab4a].
︙ | ︙ | |||
54 55 56 57 58 59 60 | objc_autoreleasePoolPop(pool); return [OFString stringWithCString: cString encoding: OF_STRING_ENCODING_ASCII length: digestSize * 2]; } | | | | | | | | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | objc_autoreleasePoolPop(pool); return [OFString stringWithCString: cString encoding: OF_STRING_ENCODING_ASCII length: digestSize * 2]; } - (OFString *)stringByMD5Hashing { return [self of_cryptoHashWithClass: [OFMD5Hash class]]; } - (OFString *)stringByRIPEMD160Hashing { return [self of_cryptoHashWithClass: [OFRIPEMD160Hash class]]; } - (OFString *)stringBySHA1Hashing { return [self of_cryptoHashWithClass: [OFSHA1Hash class]]; } - (OFString *)stringBySHA224Hashing { return [self of_cryptoHashWithClass: [OFSHA224Hash class]]; } - (OFString *)stringBySHA256Hashing { return [self of_cryptoHashWithClass: [OFSHA256Hash class]]; } - (OFString *)stringBySHA384Hashing { return [self of_cryptoHashWithClass: [OFSHA384Hash class]]; } - (OFString *)stringBySHA512Hashing { return [self of_cryptoHashWithClass: [OFSHA512Hash class]]; } @end |
Modified src/OFString+CryptoHashing.h from [562278ea0b] to [a8ec191fe6].
︙ | ︙ | |||
25 26 27 28 29 30 31 | } #endif @interface OFString (CryptoHashing) /** * @brief The MD5 hash of the string as a string. */ | | | | | | | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | } #endif @interface OFString (CryptoHashing) /** * @brief The MD5 hash of the string as a string. */ @property (readonly, nonatomic) OFString *stringByMD5Hashing; /** * @brief The RIPEMD-160 hash of the string as a string. */ @property (readonly, nonatomic) OFString *stringByRIPEMD160Hashing; /** * @brief The SHA-1 hash of the string as a string. */ @property (readonly, nonatomic) OFString *stringBySHA1Hashing; /** * @brief The SHA-224 hash of the string as a string. */ @property (readonly, nonatomic) OFString *stringBySHA224Hashing; /** * @brief The SHA-256 hash of the string as a string. */ @property (readonly, nonatomic) OFString *stringBySHA256Hashing; /** * @brief The SHA-384 hash of the string as a string. */ @property (readonly, nonatomic) OFString *stringBySHA384Hashing; /** * @brief The SHA-512 hash of the string as a string. */ @property (readonly, nonatomic) OFString *stringBySHA512Hashing; @end OF_ASSUME_NONNULL_END |
Modified src/OFString+CryptoHashing.m from [826ee219c6] to [e8341b8291].
︙ | ︙ | |||
53 54 55 56 57 58 59 | objc_autoreleasePoolPop(pool); return [OFString stringWithCString: cString encoding: OF_STRING_ENCODING_ASCII length: digestSize * 2]; } | | | | | | | | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | objc_autoreleasePoolPop(pool); return [OFString stringWithCString: cString encoding: OF_STRING_ENCODING_ASCII length: digestSize * 2]; } - (OFString *)stringByMD5Hashing { return [self of_cryptoHashWithClass: [OFMD5Hash class]]; } - (OFString *)stringByRIPEMD160Hashing { return [self of_cryptoHashWithClass: [OFRIPEMD160Hash class]]; } - (OFString *)stringBySHA1Hashing { return [self of_cryptoHashWithClass: [OFSHA1Hash class]]; } - (OFString *)stringBySHA224Hashing { return [self of_cryptoHashWithClass: [OFSHA224Hash class]]; } - (OFString *)stringBySHA256Hashing { return [self of_cryptoHashWithClass: [OFSHA256Hash class]]; } - (OFString *)stringBySHA384Hashing { return [self of_cryptoHashWithClass: [OFSHA384Hash class]]; } - (OFString *)stringBySHA512Hashing { return [self of_cryptoHashWithClass: [OFSHA512Hash class]]; } @end |
Modified tests/OFDataTests.m from [5c0a7f22cc] to [145ac3ede5].
︙ | ︙ | |||
164 165 166 167 168 169 170 | EXPECT_EXCEPTION(@"-[subdataWithRange:] failing on out of range #1", OFOutOfRangeException, [immutable subdataWithRange: of_range(7, 1)]) EXPECT_EXCEPTION(@"-[subdataWithRange:] failing on out of range #2", OFOutOfRangeException, [mutable subdataWithRange: of_range(6, 1)]) | > | | | | > | | > | | > | | > | | > > | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | EXPECT_EXCEPTION(@"-[subdataWithRange:] failing on out of range #1", OFOutOfRangeException, [immutable subdataWithRange: of_range(7, 1)]) EXPECT_EXCEPTION(@"-[subdataWithRange:] failing on out of range #2", OFOutOfRangeException, [mutable subdataWithRange: of_range(6, 1)]) TEST(@"-[stringByMD5Hashing]", [mutable.stringByMD5Hashing isEqual: @"ab56b4d92b40713acc5af89985d4b786"]) TEST(@"-[stringByRIPEMD160Hashing]", [mutable.stringByRIPEMD160Hashing isEqual: @"973398b6e6c6cfa6b5e6a5173f195ce3274bf828"]) TEST(@"-[stringBySHA1Hashing]", [mutable.stringBySHA1Hashing isEqual: @"03de6c570bfe24bfc328ccd7ca46b76eadaf4334"]) TEST(@"-[stringBySHA224Hashing]", [mutable.stringBySHA224Hashing isEqual: @"bdd03d560993e675516ba5a50638b6531ac2ac3d5847c61916cfced6" ]) TEST(@"-[stringBySHA256Hashing]", [mutable.stringBySHA256Hashing isEqual: @"36bbe50ed96841d10443bcb670d6554f0a34b761be67ec9c4a8ad2c0" @"c44ca42c"]) TEST(@"-[stringBySHA384Hashing]", [mutable.stringBySHA384Hashing isEqual: @"4c525cbeac729eaf4b4665815bc5db0c84fe6300068a727cf74e2813" @"521565abc0ec57a37ee4d8be89d097c0d2ad52f0"]) TEST(@"-[stringBySHA512Hashing]", [mutable.stringBySHA512Hashing isEqual: @"878ae65a92e86cac011a570d4c30a7eaec442b85ce8eca0c2952b5e3" @"cc0628c2e79d889ad4d5c7c626986d452dd86374b6ffaa7cd8b67665" @"bef2289a5c70b0a1"]) TEST(@"-[stringByBase64Encoding]", [mutable.stringByBase64Encoding isEqual: @"YWJjZGU="]) TEST(@"+[dataWithBase64EncodedString:]", memcmp([[OFData dataWithBase64EncodedString: @"YWJjZGU="] items], "abcde", 5) == 0) |
︙ | ︙ |
Modified tests/OFStringTests.m from [e616a01e33] to [bc3d5b4b0a].
︙ | ︙ | |||
1204 1205 1206 1207 1208 1209 1210 | TEST(@"-[UTF32String]", (ua = C(@"fööbär🀺").UTF32String) && !memcmp(ua, ucstr + 1, of_string_utf32_length(ucstr) * 4) && (ua = [C(@"fööbär🀺") UTF32StringWithByteOrder: SWAPPED_BYTE_ORDER]) && !memcmp(ua, sucstr + 1, of_string_utf32_length(sucstr) * 4)) #undef SWAPPED_BYTE_ORDER | | > | | | < | > | | | | | | | | | > | 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 | TEST(@"-[UTF32String]", (ua = C(@"fööbär🀺").UTF32String) && !memcmp(ua, ucstr + 1, of_string_utf32_length(ucstr) * 4) && (ua = [C(@"fööbär🀺") UTF32StringWithByteOrder: SWAPPED_BYTE_ORDER]) && !memcmp(ua, sucstr + 1, of_string_utf32_length(sucstr) * 4)) #undef SWAPPED_BYTE_ORDER TEST(@"-[stringByMD5Hashing]", [C(@"asdfoobar").stringByMD5Hashing isEqual: @"184dce2ec49b5422c7cfd8728864db4c"]) TEST(@"-[stringByRIPEMD160Hashing]", [C(@"asdfoobar").stringByRIPEMD160Hashing isEqual: @"021d773b0fac06eb6755ca6aa58a580c980f7f13"]) TEST(@"-[stringBySHA1Hashing]", [C(@"asdfoobar").stringBySHA1Hashing isEqual: @"f5f81ac0a8b5cbfdc4585ec1ad32e7b3a12b9b49"]) TEST(@"-[stringBySHA224Hashing]", [C(@"asdfoobar").stringBySHA224Hashing isEqual: @"5a06822dcbd5a874f67d062b80b9d8a9cb9b5b303960b9da9290c192" ]) TEST(@"-[stringBySHA256Hashing]", [C(@"asdfoobar").stringBySHA256Hashing isEqual: @"28e65b1dcd7f6ce2ea6277b15f87b913628b5500bf7913a2bbf4cedc" @"fa1215f6"]) TEST(@"-[stringBySHA384Hashing]", [C(@"asdfoobar").stringBySHA384Hashing isEqual: @"73286da882ffddca2f45e005cfa6b44f3fc65bfb26db1d087ded2f9c" @"279e5addf8be854044bca0cece073fce28eec7d9"]) TEST(@"-[stringBySHA512Hashing]", [C(@"asdfoobar").stringBySHA512Hashing isEqual: @"0464c427da158b02161bb44a3090bbfc594611ef6a53603640454b56" @"412a9247c3579a329e53a5dc74676b106755e3394f9454a2d4227324" @"2615d32f80437d61"]) cs = [OFCharacterSet characterSetWithCharactersInString: @"abfo'_~$🍏"]; TEST(@"-[stringByURLEncodingWithAllowedCharacters:]", [[C(@"foo\"ba'_~$]🍏🍌") stringByURLEncodingWithAllowedCharacters: cs] isEqual: @"foo%22ba'_~$%5D🍏%F0%9F%8D%8C"]) TEST(@"-[stringByURLDecoding]", |
︙ | ︙ |