Differences From Artifact [db4af5bb82]:
- File utils/ofhash/OFHash.m — part of check-in [e0b9167693] at 2016-02-21 15:37:42 on branch trunk — Make use of C99-style for loops (user: js, size: 3394) [annotate] [blame] [check-ins using]
To Artifact [14d7516824]:
- File
utils/ofhash/OFHash.m
— part of check-in
[951f530aee]
at
2016-07-24 00:06:30
on branch trunk
— Rename OFHash to OFCryptoHash
OFHash is too generic, as this protocol is for cryptographic hashes. It
also solves the ambiguity of the +[hash] method (which is now
+[cryptoHash]), which conflicted with -[hash] on the class itself,
resulting in classes conforming to OFHash not being able to be used as a
key in an OFDictionary. (user: js, size: 3448) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
43 44 45 46 47 48 49 | @"Usage: %@ [md5|rmd160|sha1|sha224|sha256|sha384|sha512] " @"file1 [file2 ...]\n", [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } | | | | | | | | | | | 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | @"Usage: %@ [md5|rmd160|sha1|sha224|sha256|sha384|sha512] " @"file1 [file2 ...]\n", [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } static id <OFCryptoHash> hashForName(OFString *name) { if ([name isEqual: @"md5"]) return [OFMD5Hash cryptoHash]; else if ([name isEqual: @"rmd160"] || [name isEqual: @"ripemd160"]) return [OFRIPEMD160Hash cryptoHash]; else if ([name isEqual: @"sha1"]) return [OFSHA1Hash cryptoHash]; else if ([name isEqual: @"sha224"]) return [OFSHA224Hash cryptoHash]; else if ([name isEqual: @"sha256"]) return [OFSHA256Hash cryptoHash]; else if ([name isEqual: @"sha384"]) return [OFSHA384Hash cryptoHash]; else if ([name isEqual: @"sha512"]) return [OFSHA512Hash cryptoHash]; return nil; } @implementation OFHash - (void)applicationDidFinishLaunching { OFArray OF_GENERIC(OFString*) *arguments = [OFApplication arguments]; id <OFCryptoHash> hash; bool first = true; int exitStatus = 0; if ([arguments count] < 2) help(); if ((hash = hashForName([arguments firstObject])) == nil) |
︙ | ︙ |