Click here to Skip to main content
15,390,952 members
Home / Discussions / iOS
   

iOS

 
PinnedPLEASE READ: How to get an answer to your question Pin
Chris Maunder13-Jan-15 15:36
cofounderChris Maunder13-Jan-15 15:36 
QuestionNot Enough Storage,这堆英文是什么鬼? Pin
xnny24-Jul-22 18:36
Memberxnny24-Jul-22 18:36 
AnswerRe: Not Enough Storage,这堆英文是什么鬼? Pin
OriginalGriff24-Jul-22 18:41
mveOriginalGriff24-Jul-22 18:41 
QuestionHowto: Exchange data from network to mobile app Pin
David_DK9-Jan-22 21:17
MemberDavid_DK9-Jan-22 21:17 
AnswerRe: Howto: Exchange data from network to mobile app Pin
Richard Deeming9-Jan-22 21:37
mveRichard Deeming9-Jan-22 21:37 
AnswerRe: Howto: Exchange data from network to mobile app Pin
Member 155103607-Feb-22 1:54
MemberMember 155103607-Feb-22 1:54 
AnswerRe: Howto: Exchange data from network to mobile app Pin
Member 1551036027-Apr-22 3:30
MemberMember 1551036027-Apr-22 3:30 
QuestionAES-GCM 256 Encrypt & Decrypt in iOS Swift Sync with .Net output Pin
Bb M3-Jul-21 12:18
MemberBb M3-Jul-21 12:18 
I want to use AES-GCM encryption of a plaintext with 'key' only. The 'key' will be received from backend (.net), in webservice response. The same key will be used later in backend as well to decrypt the encrypted value.

I have used extension as follwoing

To generate string to Symetric key

extension SymmetricKey {
init(string keyString: String, size: SymmetricKeySize = .bits256) throws {
guard var keyData = keyString.data(using: .utf8) else {
  print("Could not create base64 encoded Data from String.")
  throw CryptoKitError.incorrectParameterSize
}

let keySizeBytes = size.bitCount / 8
keyData = keyData.subdata(in: 0..<keySizeBytes)

guard keyData.count >= keySizeBytes else { throw CryptoKitError.incorrectKeySize }
self.init(data: keyData)
} }

Encryption & Decryption code snipet:

func aesgcmEncryptDecrypt() {
        let str : String = "FwhXRYJ$xLf?^Kh6_&YfTJ%RuG+EqcTY"    
        var key : SymmetricKey = SymmetricKey(size: .bits256)
        do{
            key = try SymmetricKey(string: str)
        }catch{        
        }
        let plain = "HOW ARE YOU?"
        let nonce = try! AES.GCM.Nonce(data: Data(base64Encoded: "fv1nixTVoYpSvpdA")!)
        let tag = Data(base64Encoded: "e1eIgoB4+lA/j3KDHhY4BQ==")!
        // Encrypt
        let sealedBox = try! AES.GCM.seal(plain.data(using: .utf8)!, using: key, 
        nonce: nonce, authenticating: tag)
        // Decrypt
        let sealedBoxRestored = try! AES.GCM.SealedBox(combined: sealedBox.combined!)
        let decrypted = try! AES.GCM.open(sealedBoxRestored, using: key, 
        authenticating: tag)
        Swift.print("Combined:\n\(sealedBox.combined!.base64EncodedString())\n")
        Swift.print("Cipher:\n\(sealedBox.ciphertext.base64EncodedString())\n")
        Swift.print("Nonce:\n\(nonce.withUnsafeBytes { 
            Data(Array($0)).base64EncodedString() })\n")
        Swift.print("Tag:\n\(tag.base64EncodedString())\n")
        Swift.print("Decrypted:\n\(String(data: decrypted, encoding: .utf8)!)\n")
    }
Our(generated from this code & .Net code) encrypted text is not matching. Anyone can help me, what I am doing wrong, detailing will be more helpful. Basically I was looking for saloution in Objective-C but I did not get any supported library for Objective-C.

QuestionGetComputerObjectNameW Win32 equivalent iOS API Pin
rajneshmalik25-Mar-21 22:34
Memberrajneshmalik25-Mar-21 22:34 
Questionmacos offset value Pin
dsec1225-Feb-21 18:58
Memberdsec1225-Feb-21 18:58 
AnswerRe: macos offset value Pin
Richard MacCutchan25-Feb-21 23:18
mveRichard MacCutchan25-Feb-21 23:18 
GeneralRe: macos offset value Pin
dsec1225-Feb-21 23:24
Memberdsec1225-Feb-21 23:24 
Jokejoke Pin
Member 149089966-Aug-20 23:55
MemberMember 149089966-Aug-20 23:55 
QuestionIOS Pin
Member 149089967-Aug-20 0:16
MemberMember 149089967-Aug-20 0:16 
AnswerRe: IOS Pin
Richard MacCutchan7-Aug-20 2:42
mveRichard MacCutchan7-Aug-20 2:42 
AnswerRe: IOS Pin
zoyafatima8-Oct-21 4:20
professionalzoyafatima8-Oct-21 4:20 
AnswerRe: IOS Pin
novelsmith13-Oct-21 7:22
professionalnovelsmith13-Oct-21 7:22 
QuestionWebview or Native App for electronic signature form Pin
jlmto15-Jan-20 20:40
Memberjlmto15-Jan-20 20:40 
AnswerMessage Closed Pin
22-Aug-20 18:07
MemberMember 1492059722-Aug-20 18:07 
AnswerRe: Webview or Native App for electronic signature form Pin
Member 155103604-May-22 2:07
MemberMember 155103604-May-22 2:07 
QuestionWhat is free solution to intergrate Digital Signature to App Pin
Member 1471406212-Jan-20 6:29
MemberMember 1471406212-Jan-20 6:29 
QuestionRe: What is free solution to intergrate Digital Signature to App Pin
David Crow12-Jan-20 13:36
MemberDavid Crow12-Jan-20 13:36 
AnswerRe: What is free solution to intergrate Digital Signature to App Pin
Richard MacCutchan12-Jan-20 22:14
mveRichard MacCutchan12-Jan-20 22:14 
AnswerRe: What is free solution to intergrate Digital Signature to App Pin
Member 1471406212-Jan-20 23:05
MemberMember 1471406212-Jan-20 23:05 
GeneralRe: What is free solution to intergrate Digital Signature to App Pin
Richard MacCutchan13-Jan-20 0:35
mveRichard MacCutchan13-Jan-20 0:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.