You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
3.9 KiB

//
// MOBFDataUtils.h
// MOBFoundation
//
// Created by vimfung on 15-1-16.
// Copyright (c) 2015年 MOB. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CommonCrypto/CommonCrypto.h>
#import <zlib.h>
/**
*
*/
@interface MOBFData : NSObject
/**
NSData对象转换为NSString对象json解析错误问题
@param data data
@return
*/
+ (NSString *)stringByData:(NSData *)data;
/**
* 使HMAC-SHA1进行加密
*
* @param data
* @param key
*
* @return
*/
+ (NSData *)hmacSha1Data:(NSData *)data forKey:(NSData *)key;
/**
使HMAC-MD5进行签名
@param data
@param key
@return
*/
+ (NSData *)hmacMd5Data:(NSData *)data forKey:(NSData *)key;
/**
* MD5签名
*
* @param data
*
* @return
*/
+ (NSData *)md5Data:(NSData *)data;
/**
* AES128加密
*
* @param data
* @param key
* @param encoding
*
* @return
*/
+ (NSData *)aes128EncryptData:(NSData *)data
key:(NSString *)key
encoding:(NSStringEncoding)encoding;
/**
* AES128解密
*
* @param data
* @param key
* @param encoding
*
* @return
*/
+ (NSData *)aes128DecryptData:(NSData *)data
key:(NSString *)key
encoding:(NSStringEncoding)encoding;
/**
* AES128加密
*
* @param data
* @param key
* @param options
*
* @return
*/
+ (NSData *)aes128EncryptData:(NSData *)data
key:(NSData *)key
options:(CCOptions)options;
/**
* AES128解密
*
* @param data
* @param key
* @param options
*
* @return
*/
+ (NSData *)aes128DecryptData:(NSData *)data
key:(NSData *)key
options:(CCOptions)options;
/**
* 使GZip压缩数据
*
* @param data
*
* @return
*/
+ (NSData *)compressDataUsingGZip:(NSData *)data;
/**
* 使GZip解压缩数据
*
* @param data
*
* @return
*/
+ (NSData *)uncompressDataUsingGZip:(NSData *)data;
/**
* MD5签名
*
* @param data
*
* @return
*/
+ (NSString *)stringByMD5Data:(NSData *)data;
/**
* 使BASE64编码数据
*
* @param data
*
* @return
*/
+ (NSString *)stringByBase64EncodeData:(NSData *)data;
/**
* CRC32校验
*
* @param data
*
* @return
*/
+ (uLong)valueByCRC32Data:(NSData *)data;
/**
* CRC32检验
*
* @param data
*
* @return
*/
+ (NSString *)stringByCRC32Data:(NSData *)data;
/**
* 16
*
* @param data
*
* @return
*/
+ (NSString *)hexStringByData:(NSData *)data;
/**
* 32
*
* @param value
* @param data
*/
+ (void)writeInt32:(int32_t)value toData:(NSMutableData *)data;
/**
* 16
*
* @param value
* @param data
*/
+ (void)writeInt16:(int16_t)value toData:(NSMutableData *)data;
/**
* 16
*
* @param data
* @param offset
*
* @return
*/
+ (int16_t)readInt16FromData:(NSData *)data offset:(NSInteger)offset;
/**
* 32
*
* @param data
* @param offset
*
* @return
*/
+ (int32_t)readInt32FromData:(NSData *)data offset:(NSInteger)offset;
@end