This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088
Dependents: MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more
NyLPC_cBase64.c
00001 /* 00002 * NyLPC_cBase64.c 00003 * 00004 * Created on: 2013/09/04 00005 * Author: nyatla 00006 */ 00007 00008 #ifndef NYLPC_CBASE64_C_ 00009 #define NYLPC_CBASE64_C_ 00010 00011 #include "NyLPC_cBase64.h" 00012 00013 /** 00014 * @param i_src 00015 * @param length 00016 * @param i_dest 00017 * Base64文字列の出力領域. length/3*4+1の長さが必要。 00018 */ 00019 void NyLPC_cBase64_encode(const NyLPC_TChar* i_src,NyLPC_TUInt16 length,char* i_dest) 00020 { 00021 const static char* B64CODE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 00022 NyLPC_TUInt16 s,d; 00023 d=0; 00024 for(s=0; s<(length-2); s+=3){ 00025 i_dest[d++]=B64CODE[((0xfc&i_src[s+0])>>2)]; 00026 i_dest[d++]=B64CODE[((0x03&i_src[s+0])<<4)|((0xf0&i_src[s+1])>>4)]; 00027 i_dest[d++]=B64CODE[((0x0f&i_src[s+1])<<2)|((0xc0&i_src[s+2])>>6)]; 00028 i_dest[d++]=B64CODE[((0x3f&i_src[s+2])>>0)]; 00029 } 00030 s=length-length%3; 00031 switch(length%3){ 00032 case 1: 00033 i_dest[d++]=B64CODE[((0xfc&i_src[s+0])>>2)]; 00034 i_dest[d++]=B64CODE[((0x03&i_src[s+0])<<4)]; 00035 break; 00036 case 2: 00037 i_dest[d++]=B64CODE[((0xfc&i_src[s+0])>>2)]; 00038 i_dest[d++]=B64CODE[((0x03&i_src[s+0])<<4)|((0xf0&i_src[s+1])>>4)]; 00039 i_dest[d++]=B64CODE[((0x0f&i_src[s+1])<<2)]; 00040 break; 00041 } 00042 //文字数 00043 while(d%4!=0){ 00044 i_dest[d++]='='; 00045 } 00046 i_dest[d]='\0'; 00047 } 00048 00049 00050 00051 #endif /* NYLPC_CBASE64_C_ */ 00052
Generated on Tue Jul 12 2022 15:46:15 by 1.7.2