-
Notifications
You must be signed in to change notification settings - Fork 7
/
SQLite3ExtCrypto.c
62 lines (57 loc) · 2.29 KB
/
SQLite3ExtCrypto.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
//
// SQLite3ExtCrypto.c
// CoreSQLite3
//
// Copyright 2011 Mirek Rusin <mirek [at] me [dot] com>
//
#include "SQLite3ExtCrypto.h"
void __SQLite3ExtCryptoMD5(sqlite3_context *context, int argc, sqlite3_value **argv) {
if (argc == 1 && sqlite3_value_type(argv[0]) != SQLITE_NULL) {
sqlite3_result_double(context, sin(sqlite3_value_double(argv[0])));
//#if (TARGET_OS_IPHONE)
// CC_MD5_CTX mdctx;
// CC_MD5_Init(&mdctx);
// unsigned char buffer[CC_MD5_DIGEST_LENGTH];
// CC_MD5_Update(&mdctx, CFDataGetBytePtr(data), CFDataGetLength(data));
// CC_MD5_Final(buffer, &mdctx);
// //return CFDataCreate(allocator, buffer, CC_MD5_DIGEST_LENGTH);
//#else
// EVP_MD_CTX mdctx;
// unsigned char buffer[EVP_MAX_MD_SIZE];
// unsigned int length = 0;
// CFMutableDataRef data = CFDataCreateMutable(allocator, 0);
// EVP_DigestInit(&mdctx, EVP_md5());
// __WebSocketDataAppendKey(data, key1);
// __WebSocketDataAppendKey(data, key2);
// CFDataAppendBytes(data, CFDataGetBytePtr(key3), CFDataGetLength(key3));
// EVP_DigestUpdate(&mdctx, CFDataGetBytePtr(data), CFDataGetLength(data));
// EVP_DigestFinal(&mdctx, buffer, &length);
// CFRelease(data);
// return CFDataCreate(allocator, buffer, length);
//#endif
} else {
sqlite3_result_null(context);
}
}
//SQLite3Status SQLite3ExtRegisterMD5(SQLite3ConnectionRef connection) {
// return SQLite3ConnectionRegisterFunction(connection, CFSTR("md5"), 1, __SQLite3ExtensionsMathSin);
//}
//
//SQLite3Status SQLite3ExtUnregisterMD5(SQLite3ConnectionRef connection) {
// return SQLite3ConnectionUnregisterFunction(connection, CFSTR("md5"), 1);
//}
//void __SQLite3ExtCryptoSHA1(sqlite3_context *context, int argc, sqlite3_value **argv) {
// if (argc == 1 && sqlite3_value_type(argv[0]) != SQLITE_NULL) {
// sqlite3_result_double(context, sin(sqlite3_value_double(argv[0])));
// } else {
// sqlite3_result_null(context);
// }
//}
//
//SQLite3Status SQLite3ExtensionsMathRegisterSHA1(SQLite3ConnectionRef connection) {
// return SQLite3ConnectionRegisterFunction(connection, CFSTR("sha1"), 1, __SQLite3ExtensionsMathSin);
//}
//
//SQLite3Status SQLite3ExtensionsMathUnregisterSHA1(SQLite3ConnectionRef connection) {
// return SQLite3ConnectionUnregisterFunction(connection, CFSTR("sha1"), 1);
//}