Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Termination key for Pack in Swift 4 #67

Open
nagarajaghantasala opened this issue Jul 30, 2018 · 1 comment
Open

Termination key for Pack in Swift 4 #67

nagarajaghantasala opened this issue Jul 30, 2018 · 1 comment

Comments

@nagarajaghantasala
Copy link

nagarajaghantasala commented Jul 30, 2018

IOS app is packing the data to send to Linux Device by this framework.

Linux Device is unpacking by mpack library.

When I used Message pack v1.2.0 for Swift 2, pack in IOS App and unpack in Linux Device are working.

After I upgrade the Message Pack v3.0 for Swift 4, Pack is not working fine.

  1. Termination key is not generated in Pack for Swift 4 and whereas that key is generating for Swift 2.
  2. One extra byte is adding to before string value after packing the data in Swift 2. This is not happening in Swift 4.
  3. Which means if we compared Swift 2 and Swift 4 Hexa values, one Byte difference is appearing in Pack. Because of this unpacking is not happening in Device side.

Example Data :-

I used same String in Array data for Message pack v1.2.0 and v3.0

Message pack v1.2.0

32 Bytes :-
String : abcdefghijklmnopqrstuvwxyzabcdef

Hexa : 91d92061 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 646566

64 Bytes :-
String : abcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdef
Hexa : 91d94061 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 64656661 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 646566

128 Bytes :-
String : abcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdef
Hexa : 

91d98061 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 64656661 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 64656661 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 64656661 62636465 66676869 6a6b6c6d 6e6f7071 72737475 76777879 7a616263 646566

Message pack v3.0

32 Bytes :-
String : abcdefghijklmnopqrstuvwxyzabcdef
Hexa : 916511d1 0380d103 800078aa 31313332 31323331 323391d9 61626364 65666768 696a6b6c 6d6e6f70 71727374 75767778 797a6162 63646566

64 Bytes :-
String : abcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdef
Hexa : 91d96162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 6566

128 Bytes :-
String : abcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdef
Hexa : 91d96162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 6566

Please provide the solution for this issue.

Thanks in Advance.

@a2
Copy link
Owner

a2 commented Jul 31, 2018

Can you provide code samples that produce the output you are seeing with MessagePack.swift v3.0?

For example, if I run the following code on master I receive this output:

let string = "abcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdefabcdefghijklmnopqrstuvwxyzabcdef"
print((pack(.string(string)) as NSData).description)
<d9806162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 65666162 63646566 6768696a 6b6c6d6e 6f707172 73747576 7778797a 61626364 6566>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants