Files
keyboard/CustomKeyboard/Utils/KBSignUtils.h
2025-12-04 20:57:39 +08:00

33 lines
778 B
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// KBSignUtils.h
// keyBoard
//
// Created by Mac on 2025/12/4.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface KBSignUtils : NSObject
/// URL 编码(与后端保持一致)
+ (NSString *)urlEncode:(NSString *)value;
/// HMAC-SHA256返回十六进制小写字符串
+ (NSString *)hmacSHA256:(NSString *)data secret:(NSString *)secret;
/// 生成签名:传入参与签名的所有参数(不含 sign 自身)
+ (NSString *)signWithParams:(NSDictionary<NSString *, NSString *> *)params
secret:(NSString *)secret;
/// 秒级时间戳(字符串)
+ (NSString *)currentTimestamp;
/// 简单 nonce 生成(默认 16 位)
+ (NSString *)generateNonceWithLength:(NSUInteger)length;
@end
NS_ASSUME_NONNULL_END