SlideShare a Scribd company logo
Base64 Encoding

    Jonathan Francis Roscoe
               jjr6@aber.ac.uk
Topics of Discussion
●
    Encoding and encryption
●
    What is base64 used for?
●
    Usage of base64 encoding
●
    The algorithm
●
    Drawbacks
●
    Alternatives
Encoding and Encryption
●
    People often refer to base64 (and similar
    methods) as a form of encryption.
●
    Encoding is the process of transforming
    information from one format into another.
    –   Transfer
    –   Storage
    –   Formating (eg. LaTeX – semantics encoding)

●
    Encryption is a type of encoding that obscures
    information to make it unreadable without
    special knowledge.
What is base64?
●
    Positional notation – a quadrosexagesimal number
    system
●
    Numerals 0-9, alphabetical characters a-z and A-Z
    plus two special characters (all printable ASCII)
●   VGhlIHF1aWNrIGJyb3duIGZveCByYW4gb3ZlciB0aGUgbGF6eS
    Bkb2c=

       Value    0    1    2    3    4    5    6    7    8    9    10   11   12   13   14   15
       Base64    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    P

       Value    16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31
       Base64    Q    R    S    T    U    V    W    X    Y    Z    a    b    c    d    e    f

       Value    32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47
       Base64    g    h    i    j    k    l    m    n    o    p    q    r    s    t    u    v

       Value    48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63
       Base64    w    x    y    z    0    1    2    3    4    5    6    7    8    9    +    /
What is base64 used for?
●
    “Binary to text” encoding.
●
    Primarily used in SMTP - transfer protocol allows
    only 7-bit ASCII characters to be used.
●
    Base64 will encode any bit stream as a sequence
    of 7-bit ASCII characters (ie. Binary data to
    plaintext).
●
    Multipurpose Internet Mail Extensions
●
    UTF-7
●
    Anti-spam evasion
●
    Binary data embedded in XML
The Encoding Algorithm
●
     Binary data is split into groups of 24 bits (3 bytes), then
     split into 6-bit chunks and converted to the corresponding
     ASCII characters.
    Original bit stream   011010110110101001101011


    6-bit chunks          011010 110110 101001 101011


    Decimal                       26 54 41 43


    Base64                            a2pr
The Encoding Algorithm
●
     What if we don't have a multiple of 3 bytes in our
     bit stream?
    Original bit stream   01100010011011000111010101100101



    Take first 24 bits,      011000 100110 110001 110101
    split into 6-bits


    Decimal                         24 38 49 53


    Base64                            Ymx1
The Encoding Algorithm
Take remaining bits          01100101



Take first 24 bits,    011001 01xxxx xxxxxx xxxxxx
split into 6-bits

Fill incomplete bits   011001 010000 xxxxxx xxxxxx
with zeros


Decimal                          25 26


Base64, replace                  ZQ==
blank bits with '='
Other Notes
●
    33% increase in size
●
    ASCII85, Quoted-printable, 8BITMIME
●
    Privacy-Enhanced Electronic Mail was the first
    place where base64 was used
●
    Headers usually describe if a message is encoded
    in base64, it is up to the client to translate

More Related Content

What's hot

Block cipher modes of operation
Block cipher modes of operation Block cipher modes of operation
Block cipher modes of operation
harshit chavda
 
Linux Environment- Linux vs Unix
Linux Environment- Linux vs UnixLinux Environment- Linux vs Unix
Linux Environment- Linux vs Unix
Trinity Dwarka
 
Substitution cipher and Its Cryptanalysis
Substitution cipher and Its CryptanalysisSubstitution cipher and Its Cryptanalysis
Substitution cipher and Its Cryptanalysis
Sunil Meena
 
Computer Networks - Error Detection & Error Correction
Computer Networks - Error Detection & Error CorrectionComputer Networks - Error Detection & Error Correction
Computer Networks - Error Detection & Error Correction
Saikrishna Tanguturu
 
Cryptography
CryptographyCryptography
Cryptography
jayashri kolekar
 
Modes of Operation
Modes of Operation Modes of Operation
Modes of Operation
Showkot Usman
 
Ipsec
IpsecIpsec
Symmetric encryption
Symmetric encryptionSymmetric encryption
Symmetric encryption
DR RICHMOND ADEBIAYE
 
IP security
IP securityIP security
IP security
shraddha mane
 
One time pad Encryption:
One time pad Encryption:One time pad Encryption:
One time pad Encryption:
Asad Ali
 
OWASP AppSecCali 2015 - Marshalling Pickles
OWASP AppSecCali 2015 - Marshalling PicklesOWASP AppSecCali 2015 - Marshalling Pickles
OWASP AppSecCali 2015 - Marshalling Pickles
Christopher Frohoff
 
Conventional Encryption NS2
Conventional Encryption NS2Conventional Encryption NS2
Conventional Encryption NS2koolkampus
 
overview of cryptographic techniques
overview of cryptographic techniquesoverview of cryptographic techniques
overview of cryptographic techniques
Shubham Jain
 
Enumeration and system hacking
Enumeration and system hackingEnumeration and system hacking
Enumeration and system hacking
begmohsin
 
Message Authentication Code & HMAC
Message Authentication Code & HMACMessage Authentication Code & HMAC
Message Authentication Code & HMAC
Krishna Gehlot
 
symmetric key encryption algorithms
 symmetric key encryption algorithms symmetric key encryption algorithms
symmetric key encryption algorithms
Rashmi Burugupalli
 

What's hot (20)

Block cipher modes of operation
Block cipher modes of operation Block cipher modes of operation
Block cipher modes of operation
 
DES
DESDES
DES
 
Linux Environment- Linux vs Unix
Linux Environment- Linux vs UnixLinux Environment- Linux vs Unix
Linux Environment- Linux vs Unix
 
Substitution cipher and Its Cryptanalysis
Substitution cipher and Its CryptanalysisSubstitution cipher and Its Cryptanalysis
Substitution cipher and Its Cryptanalysis
 
Kerberos
KerberosKerberos
Kerberos
 
Computer Networks - Error Detection & Error Correction
Computer Networks - Error Detection & Error CorrectionComputer Networks - Error Detection & Error Correction
Computer Networks - Error Detection & Error Correction
 
Cryptography
CryptographyCryptography
Cryptography
 
Modes of Operation
Modes of Operation Modes of Operation
Modes of Operation
 
Ipsec
IpsecIpsec
Ipsec
 
Symmetric encryption
Symmetric encryptionSymmetric encryption
Symmetric encryption
 
OSI Model
OSI ModelOSI Model
OSI Model
 
IP security
IP securityIP security
IP security
 
One time pad Encryption:
One time pad Encryption:One time pad Encryption:
One time pad Encryption:
 
OWASP AppSecCali 2015 - Marshalling Pickles
OWASP AppSecCali 2015 - Marshalling PicklesOWASP AppSecCali 2015 - Marshalling Pickles
OWASP AppSecCali 2015 - Marshalling Pickles
 
Conventional Encryption NS2
Conventional Encryption NS2Conventional Encryption NS2
Conventional Encryption NS2
 
overview of cryptographic techniques
overview of cryptographic techniquesoverview of cryptographic techniques
overview of cryptographic techniques
 
Ch14
Ch14Ch14
Ch14
 
Enumeration and system hacking
Enumeration and system hackingEnumeration and system hacking
Enumeration and system hacking
 
Message Authentication Code & HMAC
Message Authentication Code & HMACMessage Authentication Code & HMAC
Message Authentication Code & HMAC
 
symmetric key encryption algorithms
 symmetric key encryption algorithms symmetric key encryption algorithms
symmetric key encryption algorithms
 

Similar to Base64 Encoding

4-DES.pdf
4-DES.pdf4-DES.pdf
4-DES.pdf
ShimoFcis
 
Cryptography Symmetric Key Algorithm (CSE)
Cryptography Symmetric Key Algorithm (CSE)Cryptography Symmetric Key Algorithm (CSE)
Cryptography Symmetric Key Algorithm (CSE)
SoumyaBhattacharyya14
 
Bits and the organization of memory
Bits and the organization of memoryBits and the organization of memory
Bits and the organization of memory
dmendonsa
 
Cryptographic algorithms
Cryptographic algorithmsCryptographic algorithms
Cryptographic algorithms
Anamika Singh
 
Talk at dnGASP workshop, April 5, 2011
Talk at dnGASP workshop, April 5, 2011Talk at dnGASP workshop, April 5, 2011
Talk at dnGASP workshop, April 5, 2011Fedor Tsarev
 
Pointer in c
Pointer in cPointer in c
Pointer in c
AvichalVishnoi
 
Information and network security 20 data encryption standard des
Information and network security 20 data encryption standard desInformation and network security 20 data encryption standard des
Information and network security 20 data encryption standard des
Vaibhav Khanna
 
Modern symmetric cipher
Modern symmetric cipherModern symmetric cipher
Modern symmetric cipher
Rupesh Mishra
 
Block Cipher.cryptography_miu_year5.pptx
Block Cipher.cryptography_miu_year5.pptxBlock Cipher.cryptography_miu_year5.pptx
Block Cipher.cryptography_miu_year5.pptx
HodaAhmedBekhitAhmed
 
Block ciphers & public key cryptography
Block ciphers & public key cryptographyBlock ciphers & public key cryptography
Block ciphers & public key cryptography
RAMPRAKASHT1
 
1 DES.pdf
1 DES.pdf1 DES.pdf
1 DES.pdf
nitin571047
 
Two fish & Rijndael (AES) Encryption Algorithm
Two fish & Rijndael (AES) Encryption AlgorithmTwo fish & Rijndael (AES) Encryption Algorithm
Two fish & Rijndael (AES) Encryption Algorithm
Rifat Tasnim
 
03 UNIT-2.pdf
03 UNIT-2.pdf03 UNIT-2.pdf
03 UNIT-2.pdf
31ABINESHWARANG
 
AES.pptx
AES.pptxAES.pptx
AES.pptx
RizwanBasha12
 
Modern block cipher
Modern block cipherModern block cipher
Modern block cipher
Udit Mishra
 
javaPrimitiveTypes.pptx
javaPrimitiveTypes.pptxjavaPrimitiveTypes.pptx
javaPrimitiveTypes.pptx
MattMarino13
 
Data Communication & Computer Networks : Data Types
Data Communication & Computer Networks : Data TypesData Communication & Computer Networks : Data Types
Data Communication & Computer Networks : Data Types
Dr Rajiv Srivastava
 
chap3.pdf
chap3.pdfchap3.pdf
chap3.pdf
NickySanthosh1
 

Similar to Base64 Encoding (20)

4-DES.pdf
4-DES.pdf4-DES.pdf
4-DES.pdf
 
Cryptography Symmetric Key Algorithm (CSE)
Cryptography Symmetric Key Algorithm (CSE)Cryptography Symmetric Key Algorithm (CSE)
Cryptography Symmetric Key Algorithm (CSE)
 
Bits and the organization of memory
Bits and the organization of memoryBits and the organization of memory
Bits and the organization of memory
 
Cryptographic algorithms
Cryptographic algorithmsCryptographic algorithms
Cryptographic algorithms
 
IDEA.ppt
IDEA.pptIDEA.ppt
IDEA.ppt
 
Talk at dnGASP workshop, April 5, 2011
Talk at dnGASP workshop, April 5, 2011Talk at dnGASP workshop, April 5, 2011
Talk at dnGASP workshop, April 5, 2011
 
Cache mapping
Cache mappingCache mapping
Cache mapping
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Information and network security 20 data encryption standard des
Information and network security 20 data encryption standard desInformation and network security 20 data encryption standard des
Information and network security 20 data encryption standard des
 
Modern symmetric cipher
Modern symmetric cipherModern symmetric cipher
Modern symmetric cipher
 
Block Cipher.cryptography_miu_year5.pptx
Block Cipher.cryptography_miu_year5.pptxBlock Cipher.cryptography_miu_year5.pptx
Block Cipher.cryptography_miu_year5.pptx
 
Block ciphers & public key cryptography
Block ciphers & public key cryptographyBlock ciphers & public key cryptography
Block ciphers & public key cryptography
 
1 DES.pdf
1 DES.pdf1 DES.pdf
1 DES.pdf
 
Two fish & Rijndael (AES) Encryption Algorithm
Two fish & Rijndael (AES) Encryption AlgorithmTwo fish & Rijndael (AES) Encryption Algorithm
Two fish & Rijndael (AES) Encryption Algorithm
 
03 UNIT-2.pdf
03 UNIT-2.pdf03 UNIT-2.pdf
03 UNIT-2.pdf
 
AES.pptx
AES.pptxAES.pptx
AES.pptx
 
Modern block cipher
Modern block cipherModern block cipher
Modern block cipher
 
javaPrimitiveTypes.pptx
javaPrimitiveTypes.pptxjavaPrimitiveTypes.pptx
javaPrimitiveTypes.pptx
 
Data Communication & Computer Networks : Data Types
Data Communication & Computer Networks : Data TypesData Communication & Computer Networks : Data Types
Data Communication & Computer Networks : Data Types
 
chap3.pdf
chap3.pdfchap3.pdf
chap3.pdf
 

Recently uploaded

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
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 

Recently uploaded (20)

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
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 

Base64 Encoding

  • 1. Base64 Encoding Jonathan Francis Roscoe jjr6@aber.ac.uk
  • 2. Topics of Discussion ● Encoding and encryption ● What is base64 used for? ● Usage of base64 encoding ● The algorithm ● Drawbacks ● Alternatives
  • 3. Encoding and Encryption ● People often refer to base64 (and similar methods) as a form of encryption. ● Encoding is the process of transforming information from one format into another. – Transfer – Storage – Formating (eg. LaTeX – semantics encoding) ● Encryption is a type of encoding that obscures information to make it unreadable without special knowledge.
  • 4. What is base64? ● Positional notation – a quadrosexagesimal number system ● Numerals 0-9, alphabetical characters a-z and A-Z plus two special characters (all printable ASCII) ● VGhlIHF1aWNrIGJyb3duIGZveCByYW4gb3ZlciB0aGUgbGF6eS Bkb2c= Value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Base64 A B C D E F G H I J K L M N O P Value 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Base64 Q R S T U V W X Y Z a b c d e f Value 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Base64 g h i j k l m n o p q r s t u v Value 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 Base64 w x y z 0 1 2 3 4 5 6 7 8 9 + /
  • 5. What is base64 used for? ● “Binary to text” encoding. ● Primarily used in SMTP - transfer protocol allows only 7-bit ASCII characters to be used. ● Base64 will encode any bit stream as a sequence of 7-bit ASCII characters (ie. Binary data to plaintext). ● Multipurpose Internet Mail Extensions ● UTF-7 ● Anti-spam evasion ● Binary data embedded in XML
  • 6. The Encoding Algorithm ● Binary data is split into groups of 24 bits (3 bytes), then split into 6-bit chunks and converted to the corresponding ASCII characters. Original bit stream 011010110110101001101011 6-bit chunks 011010 110110 101001 101011 Decimal 26 54 41 43 Base64 a2pr
  • 7. The Encoding Algorithm ● What if we don't have a multiple of 3 bytes in our bit stream? Original bit stream 01100010011011000111010101100101 Take first 24 bits, 011000 100110 110001 110101 split into 6-bits Decimal 24 38 49 53 Base64 Ymx1
  • 8. The Encoding Algorithm Take remaining bits 01100101 Take first 24 bits, 011001 01xxxx xxxxxx xxxxxx split into 6-bits Fill incomplete bits 011001 010000 xxxxxx xxxxxx with zeros Decimal 25 26 Base64, replace ZQ== blank bits with '='
  • 9. Other Notes ● 33% increase in size ● ASCII85, Quoted-printable, 8BITMIME ● Privacy-Enhanced Electronic Mail was the first place where base64 was used ● Headers usually describe if a message is encoded in base64, it is up to the client to translate