Differences From Artifact [2a2048b5b4]:
- File
src/OFString+CryptoHashing.m
— part of check-in
[44f45c2e35]
at
2017-01-09 17:36:36
on branch trunk
— Update copyright
Forgot to add 2017, even though I already did quite some changes in
2017. (user: js, size: 2299) [annotate] [blame] [check-ins using]
To Artifact [78fa704049]:
- File
src/OFString+CryptoHashing.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 2307) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
25 26 27 28 29 30 31 | #import "OFSHA256Hash.h" #import "OFSHA384Hash.h" #import "OFSHA512Hash.h" int _OFString_CryptoHashing_reference; @implementation OFString (CryptoHashing) | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
#import "OFSHA256Hash.h"
#import "OFSHA384Hash.h"
#import "OFSHA512Hash.h"
int _OFString_CryptoHashing_reference;
@implementation OFString (CryptoHashing)
- (OFString *)OF_cryptoHashWithClass: (Class <OFCryptoHash>)class
{
void *pool = objc_autoreleasePoolPush();
id <OFCryptoHash> hash = [class cryptoHash];
size_t digestSize = [class digestSize];
const unsigned char *digest;
char cString[digestSize * 2];
|
| ︙ | ︙ | |||
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 *)MD5Hash
{
return [self OF_cryptoHashWithClass: [OFMD5Hash class]];
}
- (OFString *)RIPEMD160Hash
{
return [self OF_cryptoHashWithClass: [OFRIPEMD160Hash class]];
}
- (OFString *)SHA1Hash
{
return [self OF_cryptoHashWithClass: [OFSHA1Hash class]];
}
- (OFString *)SHA224Hash
{
return [self OF_cryptoHashWithClass: [OFSHA224Hash class]];
}
- (OFString *)SHA256Hash
{
return [self OF_cryptoHashWithClass: [OFSHA256Hash class]];
}
- (OFString *)SHA384Hash
{
return [self OF_cryptoHashWithClass: [OFSHA384Hash class]];
}
- (OFString *)SHA512Hash
{
return [self OF_cryptoHashWithClass: [OFSHA512Hash class]];
}
@end
|