[아두이노 arduino] Arduino – base64 encode and decode

Arduino contains a library that helps with base64 encode and decode. You can download it from the Library Manager. Search for base64, and install the library by Densaugeo.

Now, open a new sketch and run the following sample code −

#include "base64.hpp"

unsigned char normal_text[20] = "Hello World";
unsigned char base64_text[20];
unsigned char decoded_text[20];

void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println();

   int base64_length = encode_base64(normal_text,12,base64_text);
   Serial.print("Base64 Text: ");Serial.println((char *) base64_text);
   Serial.print("Base64 Length: ");Serial.println(base64_length);

   int decoded_length = decode_base64(base64_text,decoded_text);
   Serial.print("Decoded Text: ");Serial.println((char *)decoded_text);
   Serial.print("Decoded Length: ");Serial.println(decoded_length);
}

void loop() {
   // put your main code here, to run repeatedly:
}

Output

The Serial Monitor Output is shown below −

You can verify this output on websites like: https://base64.guru/converter/decode

As you can see, this library deals with unsigned character arrays. The base64_encode function takes three arguments −

  • The array to be converted

  • The number of elements in the array to be converted

  • The array in which to store the encoded values

It returns the length of the encoded array.

The base64_decode function takes in two arguments −

  • The array containing the encoded values

  • The array in which to store the decoded results

Since Serial.print() and its variations don't deal with unsigned char arrays, you need to cast it to a char array for printing.

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

 

 
 
Updated on: 26-Jul-2021

 

[출처] https://www.tutorialspoint.com/arduino-base64-encode-and-decode

 

 

 

 

 

 

 

 

 

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
22 [Raspberry Pi] 라즈베리파이 : 10 Uses for a Raspberry Pi in Manufacturing : 제조 분야에서의 라즈베리파이의 10가지 용도 file 졸리운_곰 2024.12.28 215
21 [Raspberry Pi] 라즈베리파이 GPIO 포트 ( LED, 버튼 ) 제어 file 졸리운_곰 2024.01.02 275
20 [Raspberry Pi] 라즈베리파이 GPIO file 졸리운_곰 2024.01.02 205
19 [Raspberry Pi] 2020년에 Raspberry Pi에서 실행할 수 있는 20가지 최고의 운영 체제 file 졸리운_곰 2024.01.02 191
18 [Raspberry Pi] 라즈베리파이 클러스터(병렬연결) file 졸리운_곰 2024.01.02 260
17 [라즈베리파이] 라즈베리파이 에뮬레이터 설치(QEMU) - raspbian jessie (4) - 한글 설정 file 졸리운_곰 2021.07.10 475
16 [라즈베리파이] 라즈베리파이 에뮬레이터 설치(QEMU) - raspbian jessie (3) 최적화 하기(raspi-config) file 졸리운_곰 2021.07.10 208
15 [라즈베리파이] 라즈베리파이 에뮬레이터 설치(QEMU) - raspbian jessie (2) - 이미지 size 늘리기 file 졸리운_곰 2021.07.08 207
14 [라즈베리파이] 라즈베리파이 에뮬레이터 설치(QEMU) - raspbian jessie (1) 프로그램설치 file 졸리운_곰 2021.07.08 209
13 Installing Latest Tensor flow and Keras on RASPBERRY PI file 졸리운_곰 2019.11.12 285
12 라즈베리파이 qemu : Raspberry Pi Emulator for Windows 10 file 졸리운_곰 2019.11.05 678
11 Raspberry Pi 3에 LAMP (Linux, Apache, MySQL, PHP) 설치하는 방법 file 졸리운_곰 2019.10.30 258
10 라즈베리파이에 OpenCV와 텐서플로(Tensorflow) 설치하기 file 졸리운_곰 2019.10.25 435
9 라즈베리파이 아두이노 연동 file 졸리운_곰 2019.10.25 517
8 TensorFlow 1.9 Officially Supports the Raspberry Pi : 라즈베리파이에서의 공식적인 텐서플로 사용 file 졸리운_곰 2019.03.18 304
7 라즈베리파이 Raspberry Pi 3 Model B+ 회로도 : raspberry pi schematic file 졸리운_곰 2019.03.17 1375
6 [Yocto] 욕토 프로젝트의 참고 링크 (학습링크) 졸리운_곰 2015.11.07 563
5 라즈베리파이 강좌모음 링크 file 졸리운_곰 2014.11.11 2938
4 라즈베리파이 클러스터 구축 : Clustering on RaspberryPi.pdf file 졸리운_곰 2014.11.11 658
3 라즈베리 파이 커널 소스 컴파일 하는 방법 졸리운_곰 2014.09.07 617
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED