swift - Why is the base 64 encoding not working? -


i trying post username , password php script, works fine when not encoded, having trouble encoding on ios end. when print crypt <64584e6c 636d3568 6257566b 59585268 50556377 4e444134 4d546335 4a6e4268 63334e33 62334a6b 5a474630 59543172 6448526e 4e6a5935 4d673d3d>, based on tutorials should getting string along lines of bxkgcgxhbmkgdgv4da==

var bodydata = "usernamedata=\(self.username.text!)&passworddata=\(self.password.text!)"       request.httpmethod = "post"     let encodestring = (bodydata.datausingencoding(nsutf8stringencoding)!);     let crypt = encodestring.base64encodeddatawithoptions(nsdatabase64encodingoptions(rawvalue: 0))     request.httpbody = crypt     print(crypt) 

  1. i wouldn't recommend using encodestring variable name type nsdata (not string).
  2. the function base64encodeddatawithoptions returns nsdata. if want string bxkgcgxhbmkgdgv4da==, can use base64encodedstringwithoptions.

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -