SlideShare a Scribd company logo
Weekly Code Drop:
Creating base-64 encoded HMAC
  Signatures with Cocoa Touch.
      Jason Hayes Christensen
          jasonc411.com




July 4 Weekly Code Drop
A number of new authentication models use
base64 encoded HMAC-SHA1 and HMAC-
SHA2/256 signatures.
  Amazon AWS uses HMAC-SHA1
  OAuth uses HMAC-SHA1 and RSA-SHA1
  OpenID uses HMAC-SHA1 and HMAC-SHA256

This is an overview of how to create these
signatures.




      July 4 Weekly Code Drop
HMAC-SHA1 HMAC-SHA256 HMAC-MD5

HMAC stands for Hashed Message Authentication Code. The
postfix after the – is the signature method.

HMAC-SHA1 Most commonly encountered

HMAC-SHA256 More secure, but has been subject to a partially
successful cryptanalysis.

HMAC-MD5 Has been subject to a fully successful cryptanalysis.




        July 4 Weekly Code Drop
HMAC in Cocoa

HMACs are easy to generate in Cocoa, one simply uses the
function:
CCHmac(signatureType,
       (const void*)[key UTF8String],
       [key length],
       (const void*)[message UTF8String],
       [message length],
       (void*)hmacOutBuffer);

This call is in the function createEncodedHMACToken in the
sample..

The hmacOutBuffer should be of length 16+1 bytes for MD5, 20+1
bytes for SHA1, and 32+1 bytes for SHA256, the hash should be
null terminated




           July 4 Weekly Code Drop
Base64 Enoding Fundamentals

Bas64 Encoding in Cocoa is a matter of creating your own.

Base64 encoding is used to convert binary data to text data. using
the non-control characters
      General : A-Za-z0-9+/
      URI safe: A-Za-z0-9-_

Filler Characters
      General: '='
      URI Safe: '*'

Filler characters are used when the three byte buffer has fewer
than three bytes in it..



         July 4 Weekly Code Drop
Base64 Encoding Method

base256 numbers are represented in 8 bits

base64 can be represented in 6 bits.

8 and 6 have a Lowest Common Multiple of 24
   3 bytes, or four base64 values.

We therefore take three bytes at a time and create four base64
values.

We concatenate the characters represented by each base64 value
in order into the return buffer.




        July 4 Weekly Code Drop
Base64 Encoding Visually
FE3225


         11111110 00110010 00100101

         111111 100011 001000 100101


                 6 3 0 3
                 3 5 8 7
                 / j   I   l   /jIl



      July 4 Weekly Code Drop
Base64 Encoding Loop




     July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
       Right Click on Targets
       Click Add->New Target...




      July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
                              Choose 'Unit Test Bundle',
                                  then click 'Next'




      July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
                                       Name the Bundle
                                       Then click “Finish”




      July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
                          Double Click on the new bundle
                           This dialog will appear
                          Click on the + button




      July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
                        Add the project as a dependency,
                        Then click Add Target




      July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
                    For libraries,
                        we must also add the library,
                    So click on the lower +




      July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
                          Select the library then
                              Then click “Add”




      July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
                       Click the red button to close




      July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
   Add a new file group to the project,
    Right click on the project
     Then select Add->New Group
     Finally, name the new Group “Tests” or something similar




       July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
   Add a new file to the Tests group
       Right click on Tests
           Then select Add->New File...




       July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
                            Select Objective-C test class,
                               Then click Next




      July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
                                Name the test class,
                                select include header,
                                choose the Test target
                                    As shown




      July 4 Weekly Code Drop
Setting up Unit Testing Step by Step
                         When ready to run unit tests,
                          set the test bundle as the
                           primary target,
                         Then build.
                             If tests fail, you will
                             get build errors.




      July 4 Weekly Code Drop
Conclusion
  What we looked at:
   Who in cloud, and auth use HMAC-SHA*** tokens.
   How to sign the message.
   How to do a base64 encoding
   How to setup unit testing

   The code is BSD license, feel free to use it, but there
   are no warranties explicit or implied, as it is purely for
   purposes of demonstration.

   The code can be accessed at:
      http://jasonc411.com/downloads.html




      July 4 Weekly Code Drop

More Related Content

Similar to Weekly Code Drop July 4, creating auth tokens

Cis247 a ilab 1 of 7 creating a user interface
Cis247 a ilab 1 of 7 creating a user interfaceCis247 a ilab 1 of 7 creating a user interface
Cis247 a ilab 1 of 7 creating a user interface
ccis224477
 
Cis247 i lab 1 of 7 creating a user interface
Cis247 i lab 1 of 7 creating a user interfaceCis247 i lab 1 of 7 creating a user interface
Cis247 i lab 1 of 7 creating a user interface
sdjdskjd9097
 
Hpalm
HpalmHpalm
Hpalm
satu2412
 
Test Drive Development
Test Drive DevelopmentTest Drive Development
Test Drive Development
satya sudheer
 
Query Management system-Iv review
Query Management system-Iv reviewQuery Management system-Iv review
Query Management system-Iv review
logeshprabu
 
How to begin with Amazon EC2?
How to begin with Amazon EC2?How to begin with Amazon EC2?
How to begin with Amazon EC2?
Cuelogic Technologies Pvt. Ltd.
 
Triggers for Admins: A Five-step Framework for Creating Triggers
Triggers for Admins: A Five-step Framework for Creating TriggersTriggers for Admins: A Five-step Framework for Creating Triggers
Triggers for Admins: A Five-step Framework for Creating Triggers
Salesforce Developers
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
Dave Haeffner
 
Handling Netcore
Handling  NetcoreHandling  Netcore
Handling Netcore
Febin Chacko
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
justmeanscsr
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
justmeanscsr
 
Review of an open source unit test tool- Cucumber_Presentation
Review of an open source unit test tool- Cucumber_PresentationReview of an open source unit test tool- Cucumber_Presentation
Review of an open source unit test tool- Cucumber_Presentation
Jabeen Shazia Posses H1 B Visa (Jazz)
 
Workshop agile testing
Workshop agile testingWorkshop agile testing
Workshop agile testing
John Marx
 
A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4
Andrey Karpov
 
Cis 247 all i labs
Cis 247 all i labsCis 247 all i labs
Cis 247 all i labs
ccis224477
 
Custom Automation Masterclass – Workshop 2: Email validation using kKckbox
Custom Automation Masterclass – Workshop 2: Email validation using kKckboxCustom Automation Masterclass – Workshop 2: Email validation using kKckbox
Custom Automation Masterclass – Workshop 2: Email validation using kKckbox
JanBogaert8
 
Telerik Test studio
Telerik Test studio Telerik Test studio
Telerik Test studio
Ahamad Sk
 
AppSec USA 2015: Customizing Burp Suite
AppSec USA 2015: Customizing Burp SuiteAppSec USA 2015: Customizing Burp Suite
AppSec USA 2015: Customizing Burp Suite
August Detlefsen
 
Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7
comp274
 
Google Hacking Lab ClassNameDate This is an introducti.docx
Google Hacking Lab ClassNameDate This is an introducti.docxGoogle Hacking Lab ClassNameDate This is an introducti.docx
Google Hacking Lab ClassNameDate This is an introducti.docx
whittemorelucilla
 

Similar to Weekly Code Drop July 4, creating auth tokens (20)

Cis247 a ilab 1 of 7 creating a user interface
Cis247 a ilab 1 of 7 creating a user interfaceCis247 a ilab 1 of 7 creating a user interface
Cis247 a ilab 1 of 7 creating a user interface
 
Cis247 i lab 1 of 7 creating a user interface
Cis247 i lab 1 of 7 creating a user interfaceCis247 i lab 1 of 7 creating a user interface
Cis247 i lab 1 of 7 creating a user interface
 
Hpalm
HpalmHpalm
Hpalm
 
Test Drive Development
Test Drive DevelopmentTest Drive Development
Test Drive Development
 
Query Management system-Iv review
Query Management system-Iv reviewQuery Management system-Iv review
Query Management system-Iv review
 
How to begin with Amazon EC2?
How to begin with Amazon EC2?How to begin with Amazon EC2?
How to begin with Amazon EC2?
 
Triggers for Admins: A Five-step Framework for Creating Triggers
Triggers for Admins: A Five-step Framework for Creating TriggersTriggers for Admins: A Five-step Framework for Creating Triggers
Triggers for Admins: A Five-step Framework for Creating Triggers
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
Handling Netcore
Handling  NetcoreHandling  Netcore
Handling Netcore
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
Review of an open source unit test tool- Cucumber_Presentation
Review of an open source unit test tool- Cucumber_PresentationReview of an open source unit test tool- Cucumber_Presentation
Review of an open source unit test tool- Cucumber_Presentation
 
Workshop agile testing
Workshop agile testingWorkshop agile testing
Workshop agile testing
 
A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4
 
Cis 247 all i labs
Cis 247 all i labsCis 247 all i labs
Cis 247 all i labs
 
Custom Automation Masterclass – Workshop 2: Email validation using kKckbox
Custom Automation Masterclass – Workshop 2: Email validation using kKckboxCustom Automation Masterclass – Workshop 2: Email validation using kKckbox
Custom Automation Masterclass – Workshop 2: Email validation using kKckbox
 
Telerik Test studio
Telerik Test studio Telerik Test studio
Telerik Test studio
 
AppSec USA 2015: Customizing Burp Suite
AppSec USA 2015: Customizing Burp SuiteAppSec USA 2015: Customizing Burp Suite
AppSec USA 2015: Customizing Burp Suite
 
Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7Cis 170 ilab 1 of 7
Cis 170 ilab 1 of 7
 
Google Hacking Lab ClassNameDate This is an introducti.docx
Google Hacking Lab ClassNameDate This is an introducti.docxGoogle Hacking Lab ClassNameDate This is an introducti.docx
Google Hacking Lab ClassNameDate This is an introducti.docx
 

Recently uploaded

National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 

Recently uploaded (20)

National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 

Weekly Code Drop July 4, creating auth tokens

  • 1. Weekly Code Drop: Creating base-64 encoded HMAC Signatures with Cocoa Touch. Jason Hayes Christensen jasonc411.com July 4 Weekly Code Drop
  • 2. A number of new authentication models use base64 encoded HMAC-SHA1 and HMAC- SHA2/256 signatures. Amazon AWS uses HMAC-SHA1 OAuth uses HMAC-SHA1 and RSA-SHA1 OpenID uses HMAC-SHA1 and HMAC-SHA256 This is an overview of how to create these signatures. July 4 Weekly Code Drop
  • 3. HMAC-SHA1 HMAC-SHA256 HMAC-MD5 HMAC stands for Hashed Message Authentication Code. The postfix after the – is the signature method. HMAC-SHA1 Most commonly encountered HMAC-SHA256 More secure, but has been subject to a partially successful cryptanalysis. HMAC-MD5 Has been subject to a fully successful cryptanalysis. July 4 Weekly Code Drop
  • 4. HMAC in Cocoa HMACs are easy to generate in Cocoa, one simply uses the function: CCHmac(signatureType, (const void*)[key UTF8String], [key length], (const void*)[message UTF8String], [message length], (void*)hmacOutBuffer); This call is in the function createEncodedHMACToken in the sample.. The hmacOutBuffer should be of length 16+1 bytes for MD5, 20+1 bytes for SHA1, and 32+1 bytes for SHA256, the hash should be null terminated July 4 Weekly Code Drop
  • 5. Base64 Enoding Fundamentals Bas64 Encoding in Cocoa is a matter of creating your own. Base64 encoding is used to convert binary data to text data. using the non-control characters General : A-Za-z0-9+/ URI safe: A-Za-z0-9-_ Filler Characters General: '=' URI Safe: '*' Filler characters are used when the three byte buffer has fewer than three bytes in it.. July 4 Weekly Code Drop
  • 6. Base64 Encoding Method base256 numbers are represented in 8 bits base64 can be represented in 6 bits. 8 and 6 have a Lowest Common Multiple of 24 3 bytes, or four base64 values. We therefore take three bytes at a time and create four base64 values. We concatenate the characters represented by each base64 value in order into the return buffer. July 4 Weekly Code Drop
  • 7. Base64 Encoding Visually FE3225 11111110 00110010 00100101 111111 100011 001000 100101 6 3 0 3 3 5 8 7 / j I l /jIl July 4 Weekly Code Drop
  • 8. Base64 Encoding Loop July 4 Weekly Code Drop
  • 9. Setting up Unit Testing Step by Step Right Click on Targets Click Add->New Target... July 4 Weekly Code Drop
  • 10. Setting up Unit Testing Step by Step Choose 'Unit Test Bundle', then click 'Next' July 4 Weekly Code Drop
  • 11. Setting up Unit Testing Step by Step Name the Bundle Then click “Finish” July 4 Weekly Code Drop
  • 12. Setting up Unit Testing Step by Step Double Click on the new bundle This dialog will appear Click on the + button July 4 Weekly Code Drop
  • 13. Setting up Unit Testing Step by Step Add the project as a dependency, Then click Add Target July 4 Weekly Code Drop
  • 14. Setting up Unit Testing Step by Step For libraries, we must also add the library, So click on the lower + July 4 Weekly Code Drop
  • 15. Setting up Unit Testing Step by Step Select the library then Then click “Add” July 4 Weekly Code Drop
  • 16. Setting up Unit Testing Step by Step Click the red button to close July 4 Weekly Code Drop
  • 17. Setting up Unit Testing Step by Step Add a new file group to the project, Right click on the project Then select Add->New Group Finally, name the new Group “Tests” or something similar July 4 Weekly Code Drop
  • 18. Setting up Unit Testing Step by Step Add a new file to the Tests group Right click on Tests Then select Add->New File... July 4 Weekly Code Drop
  • 19. Setting up Unit Testing Step by Step Select Objective-C test class, Then click Next July 4 Weekly Code Drop
  • 20. Setting up Unit Testing Step by Step Name the test class, select include header, choose the Test target As shown July 4 Weekly Code Drop
  • 21. Setting up Unit Testing Step by Step When ready to run unit tests, set the test bundle as the primary target, Then build. If tests fail, you will get build errors. July 4 Weekly Code Drop
  • 22. Conclusion What we looked at: Who in cloud, and auth use HMAC-SHA*** tokens. How to sign the message. How to do a base64 encoding How to setup unit testing The code is BSD license, feel free to use it, but there are no warranties explicit or implied, as it is purely for purposes of demonstration. The code can be accessed at: http://jasonc411.com/downloads.html July 4 Weekly Code Drop