58 lines
1.3 KiB
Objective-C
58 lines
1.3 KiB
Objective-C
//
|
||
// NSString+KYSM4.h
|
||
// Hug
|
||
//
|
||
// Created by WJT on 2018/6/11.
|
||
// Copyright © 2018年 WJT. All rights reserved.
|
||
//
|
||
|
||
#import <Foundation/Foundation.h>
|
||
|
||
@interface NSString (KYSM4)
|
||
|
||
/**
|
||
* 使用密钥和初始化向量生成CBC模式的SM4加解密对象
|
||
*
|
||
* @param secretKey 密钥
|
||
* @param iv 初始化向量
|
||
*
|
||
* @return SM4加密字符串
|
||
*/
|
||
- (nullable NSString *)encryptionWithSM4Key:(nonnull NSString *)secretKey iv:(nonnull NSString *)iv;
|
||
|
||
/**
|
||
在CBC模式下,利用给定的密钥,初始化向量,对字符串解密
|
||
|
||
@param secretKey 密钥
|
||
@param iv 初始化向量
|
||
@return SM4解密字符串
|
||
*/
|
||
- (nullable NSString *)decryptionWithSM4Key:(nonnull NSString *)secretKey iv:(nonnull NSString *)iv;
|
||
/**
|
||
* 使用密钥生成ECB模式的SM4加解密对象
|
||
*
|
||
* @param secretKey 密钥
|
||
*
|
||
* @return SM4加解密对象
|
||
*/
|
||
- (nullable NSString *)encryptionWithSM4Key:(nonnull NSString *)secretKey;
|
||
|
||
/**
|
||
* 在ECB模式下,利用给定的密钥,对字符串解密
|
||
*
|
||
* @param secretKey 密钥
|
||
*
|
||
* @return SM4解密字符串
|
||
*/
|
||
- (nullable NSString *)decryptionWithSM4Key:(nonnull NSString *)secretKey;
|
||
|
||
/**
|
||
* hmacSM3加密
|
||
*
|
||
* @param secretKey 密钥
|
||
*
|
||
* @return hmacSM3加密字符串
|
||
*/
|
||
- (nullable NSString *)encryptionWithSM3Key:(nonnull NSString *)secretKey;
|
||
@end
|