1
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyCollectedDataTypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyTrackingDomains</key>
|
||||
<array/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,212 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>files</key>
|
||||
<dict>
|
||||
<key>Headers/unimoduleXCryptoS-Swift.h</key>
|
||||
<data>
|
||||
sYrSn+RyBIFDQBszO3/P8xJljp8=
|
||||
</data>
|
||||
<key>Headers/unimoduleXCryptoS.h</key>
|
||||
<data>
|
||||
FH2SRnQAHIO8AbDZPa5/Bz/CcdA=
|
||||
</data>
|
||||
<key>Info.plist</key>
|
||||
<data>
|
||||
IVoTM86XmFTSTQOc3nqKLlrf+g4=
|
||||
</data>
|
||||
<key>Modules/module.modulemap</key>
|
||||
<data>
|
||||
Mb2Zqns/19tDjbGpiH3LGGA1fQA=
|
||||
</data>
|
||||
<key>Modules/unimoduleXCryptoS.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo</key>
|
||||
<data>
|
||||
LrNVXN9SxWbowabgwHEhjXGtoM8=
|
||||
</data>
|
||||
<key>Modules/unimoduleXCryptoS.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
|
||||
<data>
|
||||
u+u1y6eK8UyQLdXF+asiH9J61zw=
|
||||
</data>
|
||||
<key>Modules/unimoduleXCryptoS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
|
||||
<data>
|
||||
TBpJmMJe82pwDjT2PuqjFG0QOgo=
|
||||
</data>
|
||||
<key>Modules/unimoduleXCryptoS.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
|
||||
<data>
|
||||
vAWogVlQ2acSpes+rngJqaHu53s=
|
||||
</data>
|
||||
<key>Modules/unimoduleXCryptoS.swiftmodule/x86_64-apple-ios-simulator.swiftinterface</key>
|
||||
<data>
|
||||
TBpJmMJe82pwDjT2PuqjFG0QOgo=
|
||||
</data>
|
||||
<key>Modules/unimoduleXCryptoS.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
|
||||
<data>
|
||||
DYmcbJn2Wta9ChJfVGlUIOckdl0=
|
||||
</data>
|
||||
<key>config.json</key>
|
||||
<data>
|
||||
/sqVTWYkSC3IKjeGGZtJQnx8PC0=
|
||||
</data>
|
||||
</dict>
|
||||
<key>files2</key>
|
||||
<dict>
|
||||
<key>Headers/unimoduleXCryptoS-Swift.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
bTRltszQF3+fsDE5fSoWA2h4RJFMjgJiooCIolmygdk=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/unimoduleXCryptoS.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
XAsze1m7Z4PhyI2gj+RafZVS4xyqWjgvqraTawdVPMY=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Modules/module.modulemap</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
W0XF/xxiculnRfXzfkaeT5qgc+qCLcZzsOzHUDmxshc=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Modules/unimoduleXCryptoS.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
l63MWC0FBuCg1jbWMzXhOYlbdgWWib9kANlDZQDhvOQ=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Modules/unimoduleXCryptoS.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
LjfbpG0RJlR1dLq/DxB3kwt6X4B0pQQmnw5Obt8VOhU=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Modules/unimoduleXCryptoS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
tYzzmU2An+2B2UBi/H0Qkz+BkR6fVGyq0IKlEcdMCxk=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Modules/unimoduleXCryptoS.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
NXc6efR/rQre4hYKBGOWCStcK9AsMK9pnXXvCFoiq4c=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Modules/unimoduleXCryptoS.swiftmodule/x86_64-apple-ios-simulator.swiftinterface</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
tYzzmU2An+2B2UBi/H0Qkz+BkR6fVGyq0IKlEcdMCxk=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Modules/unimoduleXCryptoS.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
NAmTbjwY/t547ARB7gCdhKUdLuBnd/8815n5YixIHB8=
|
||||
</data>
|
||||
</dict>
|
||||
<key>config.json</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
aW1+rl6/vnHObZ31RQBG9uwopiZhbmvup1CuOkP3aZo=
|
||||
</data>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>rules</key>
|
||||
<dict>
|
||||
<key>^.*</key>
|
||||
<true/>
|
||||
<key>^.*\.lproj/</key>
|
||||
<dict>
|
||||
<key>optional</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1000</real>
|
||||
</dict>
|
||||
<key>^.*\.lproj/locversion.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1100</real>
|
||||
</dict>
|
||||
<key>^Base\.lproj/</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>1010</real>
|
||||
</dict>
|
||||
<key>^version.plist$</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>rules2</key>
|
||||
<dict>
|
||||
<key>.*\.dSYM($|/)</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>11</real>
|
||||
</dict>
|
||||
<key>^(.*/)?\.DS_Store$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>2000</real>
|
||||
</dict>
|
||||
<key>^.*</key>
|
||||
<true/>
|
||||
<key>^.*\.lproj/</key>
|
||||
<dict>
|
||||
<key>optional</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1000</real>
|
||||
</dict>
|
||||
<key>^.*\.lproj/locversion.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1100</real>
|
||||
</dict>
|
||||
<key>^Base\.lproj/</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>1010</real>
|
||||
</dict>
|
||||
<key>^Info\.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^PkgInfo$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^embedded\.provisionprofile$</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^version\.plist$</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"deploymentTarget": "12",
|
||||
"dependencies-pods": [
|
||||
{
|
||||
"name": "CryptoSwift",
|
||||
"version": "1.8.3"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import Foundation, { Data, JSONDecoder, NSNumber } from 'Foundation'
|
||||
import { CryptoKit, SymmetricKey } from 'CryptoKit'
|
||||
import CommonCrypto from 'CommonCrypto'
|
||||
import { UInt8, UnsafeRawBufferPointer , Int } from "Swift";
|
||||
import { RSARANDOMKEY } from "../interface.uts"
|
||||
|
||||
|
||||
|
||||
export function md5(str : string) : string {
|
||||
return UniversalCryptoHelper.md5(input = str);
|
||||
}
|
||||
export function base64Encode(str : string) : string {
|
||||
return UniversalCryptoHelper.base64Encode(input = str);
|
||||
}
|
||||
export function base64Decode(str : string) : string {
|
||||
return UniversalCryptoHelper.base64Decode(input = str);
|
||||
}
|
||||
export function sha256(str : string) : string {
|
||||
return UniversalCryptoHelper.sha256(input = str);
|
||||
}
|
||||
export function sha512(str : string) : string {
|
||||
return UniversalCryptoHelper.sha512(input = str);
|
||||
}
|
||||
export function hmacSha256(key:string,data : string) : string {
|
||||
return UniversalCryptoHelper.hmacSha256(key = key,data = data);
|
||||
}
|
||||
export function hmacSha512(key:string,data : string) : string {
|
||||
return UniversalCryptoHelper.hmacSha512(key = key,data = data);
|
||||
}
|
||||
export function sha1(str : string) : string {
|
||||
return UniversalCryptoHelper.sha1(input = str);
|
||||
}
|
||||
export function aesEncrypt(key:string,data : string,mode:string = "ECB",iv:string|null = null,keySize:number|null=null) : string {
|
||||
return UniversalCryptoHelper.aesEncrypt(input = data,key = key,mode = mode,iv = iv,keySize = (keySize==null?16:keySize!).toInt());
|
||||
}
|
||||
export function aesDecrypt(key:string,data : string,mode:string = "ECB",iv:string|null = null,keySize:number|null=null) : string {
|
||||
return UniversalCryptoHelper.aesDecrypt(input = data,key = key,mode = mode,iv = iv,keySize=(keySize==null?16:keySize!).toInt());
|
||||
}
|
||||
|
||||
/**
|
||||
* AES加密 - ArrayBuffer版本
|
||||
* @param {ArrayBuffer} key ArrayBuffer数据它会根据keySize来截取和补足0
|
||||
* @param {ArrayBuffer} data 待加密的ArrayBuffer
|
||||
* @param {string} mode ECB,CBC
|
||||
* @param {ArrayBuffer} iv 固定是16位,不足会补齐0
|
||||
* @param {number} keySize 对key的加密补位,也就是加密位数16为128,24为192,32为256
|
||||
* @returns {number[]} 加密后的数据
|
||||
*/
|
||||
export function aesEncrypt2(key:ArrayBuffer,data : ArrayBuffer,mode:string = "ECB",iv:ArrayBuffer|null = null,keySize:number|null=null) : number[] {
|
||||
|
||||
const keyArray = key.toData()
|
||||
const dataArray = data.toData()
|
||||
const ivArray = (iv == null ? null :iv.toData()) as Data|null;
|
||||
const result = UniversalCryptoHelper.aesEncrypt2(input = dataArray, key = keyArray, mode = mode, iv = ivArray, keySize = (keySize==null?16:keySize!).toInt())
|
||||
|
||||
let resuitAr:number[] = result.bytes.map((el:UInt8):number=> NSNumber.from(new Int(el)))
|
||||
return resuitAr
|
||||
}
|
||||
|
||||
/**
|
||||
* AES解密 - ArrayBuffer版本
|
||||
* @param {ArrayBuffer} key ArrayBuffer数据它会根据keySize来截取和补足0
|
||||
* @param {ArrayBuffer} data 待解密的ArrayBuffer
|
||||
* @param {string} mode ECB,CBC
|
||||
* @param {ArrayBuffer} iv 固定是16位,不足会补齐0
|
||||
* @param {number} keySize 对key的加密补位,也就是加密位数16为128,24为192,32为256
|
||||
* @returns {number[]} 解密后的数据
|
||||
*/
|
||||
export function aesDecrypt2(key:ArrayBuffer,data : ArrayBuffer,mode:string = "ECB",iv:ArrayBuffer|null = null,keySize:number|null=null) : number[] {
|
||||
const keyArray = key.toData()
|
||||
const dataArray = data.toData()
|
||||
const ivArray = (iv == null ? null :iv.toData()) as Data|null;
|
||||
|
||||
const result = UniversalCryptoHelper.aesDecrypt2(input = dataArray, key = keyArray, mode = mode, iv = ivArray, keySize = (keySize==null?16:keySize!).toInt())
|
||||
let resuitAr:number[] = result.bytes.map((el:UInt8):number=> NSNumber.from(new Int(el)))
|
||||
return resuitAr
|
||||
}
|
||||
export function desEncrypt(key:string,data : string,mode:string = "ECB",iv:string|null = null) : string {
|
||||
return UniversalCryptoHelper.desEncrypt(input = data,key = key,mode=mode,iv=iv);
|
||||
}
|
||||
export function desDecrypt(key:string,data : string,mode:string = "ECB",iv:string|null = null) : string {
|
||||
return UniversalCryptoHelper.desDecrypt(input = data,key = key,mode=mode,iv=iv);
|
||||
}
|
||||
export function generateRSAKeyPair(keySize : number = 2048) : RSARANDOMKEY {
|
||||
const crypt = UTSiOS.try(UniversalCryptoHelper.generateRSAKeyPair(keySize = keySize.toInt()),"?")
|
||||
|
||||
if(crypt==null){
|
||||
return {
|
||||
publicKey: "",
|
||||
privateKey: "",
|
||||
} as RSARANDOMKEY
|
||||
}
|
||||
return {
|
||||
publicKey: crypt!.publicKey,
|
||||
privateKey: crypt!.privateKey
|
||||
} as RSARANDOMKEY
|
||||
}
|
||||
|
||||
export function rsaEncrypt(publicKey:string,data : string) : string {
|
||||
const crypt = UTSiOS.try(UniversalCryptoHelper.rsaEncrypt(data,publicKey = publicKey),"?")
|
||||
// return UniversalCryptoHelper.rsaEncrypt(input = data,publicKey = publicKey);
|
||||
if(crypt==null) return ""
|
||||
return crypt!;
|
||||
}
|
||||
|
||||
export function rsaDecrypt(privateKey:string,data : string) : string {
|
||||
const crypt = UTSiOS.try(UniversalCryptoHelper.rsaDecrypt(data,privateKey = privateKey),"?")
|
||||
if(crypt==null) return ""
|
||||
// return UniversalCryptoHelper.rsaDecrypt(input = data,privateKey = privateKey);
|
||||
return crypt!;
|
||||
}
|
||||
//返回的是hex字符串
|
||||
export function rc4Encrypt(key:string,data : string) : string {
|
||||
return UniversalCryptoHelper.rc4Encrypt(data = data,key = key);
|
||||
}
|
||||
|
||||
// key是hex字符
|
||||
export function rc4Decrypt(key:string,data : string) : string {
|
||||
return UniversalCryptoHelper.rc4Decrypt(encryptedHex = data,key = key);
|
||||
}
|
||||
Reference in New Issue
Block a user