数据加密解密




 

【Cocos2d-x】数据加密解密 

分类: Cocos2d-x   625人阅读  评论(1)  收藏  举报

目录(?)[+]


C++的Base64算法实现


<a target=_blank id="L1" href="http://blog.csdn.net/linchaolong/article/details/41224483#L1" rel="#L1" style="text-decoration: none; color: rgb(12, 137, 207);">   1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/linchaolong/article/details/41224483#L2" rel="#L2" style="text-decoration: none; color: rgb(12, 137, 207);">   2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/linchaolong/article/details/41224483#L3" rel="#L3" style="text-decoration: none; color: rgb(12, 137, 207);">   3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/linchaolong/article/details/41224483#L4" rel="#L4" style="text-decoration: none; color: rgb(12, 137, 207);">   4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/linchaolong/article/details/41224483#L5" rel="#L5" style="text-decoration: none; color: rgb(12, 137, 207);">   5</a>
<a target=_blank id="L6" href="http://blog.csdn.net/linchaolong/article/details/41224483#L6" rel="#L6" style="text-decoration: none; color: rgb(12, 137, 207);">   6</a>
<a target=_blank id="L7" href="http://blog.csdn.net/linchaolong/article/details/41224483#L7" rel="#L7" style="text-decoration: none; color: rgb(12, 137, 207);">   7</a>
<a target=_blank id="L8" href="http://blog.csdn.net/linchaolong/article/details/41224483#L8" rel="#L8" style="text-decoration: none; color: rgb(12, 137, 207);">   8</a>
<a target=_blank id="L9" href="http://blog.csdn.net/linchaolong/article/details/41224483#L9" rel="#L9" style="text-decoration: none; color: rgb(12, 137, 207);">   9</a>
<a target=_blank id="L10" href="http://blog.csdn.net/linchaolong/article/details/41224483#L10" rel="#L10" style="text-decoration: none; color: rgb(12, 137, 207);">  10</a>
<a target=_blank id="L11" href="http://blog.csdn.net/linchaolong/article/details/41224483#L11" rel="#L11" style="text-decoration: none; color: rgb(12, 137, 207);">  11</a>
<a target=_blank id="L12" href="http://blog.csdn.net/linchaolong/article/details/41224483#L12" rel="#L12" style="text-decoration: none; color: rgb(12, 137, 207);">  12</a>
<a target=_blank id="L13" href="http://blog.csdn.net/linchaolong/article/details/41224483#L13" rel="#L13" style="text-decoration: none; color: rgb(12, 137, 207);">  13</a>
<a target=_blank id="L14" href="http://blog.csdn.net/linchaolong/article/details/41224483#L14" rel="#L14" style="text-decoration: none; color: rgb(12, 137, 207);">  14</a>
<a target=_blank id="L15" href="http://blog.csdn.net/linchaolong/article/details/41224483#L15" rel="#L15" style="text-decoration: none; color: rgb(12, 137, 207);">  15</a>
<a target=_blank id="L16" href="http://blog.csdn.net/linchaolong/article/details/41224483#L16" rel="#L16" style="text-decoration: none; color: rgb(12, 137, 207);">  16</a>
<a target=_blank id="L17" href="http://blog.csdn.net/linchaolong/article/details/41224483#L17" rel="#L17" style="text-decoration: none; color: rgb(12, 137, 207);">  17</a>
<a target=_blank id="L18" href="http://blog.csdn.net/linchaolong/article/details/41224483#L18" rel="#L18" style="text-decoration: none; color: rgb(12, 137, 207);">  18</a>
<a target=_blank id="L19" href="http://blog.csdn.net/linchaolong/article/details/41224483#L19" rel="#L19" style="text-decoration: none; color: rgb(12, 137, 207);">  19</a>
<a target=_blank id="L20" href="http://blog.csdn.net/linchaolong/article/details/41224483#L20" rel="#L20" style="text-decoration: none; color: rgb(12, 137, 207);">  20</a>
<a target=_blank id="L21" href="http://blog.csdn.net/linchaolong/article/details/41224483#L21" rel="#L21" style="text-decoration: none; color: rgb(12, 137, 207);">  21</a>
<a target=_blank id="L22" href="http://blog.csdn.net/linchaolong/article/details/41224483#L22" rel="#L22" style="text-decoration: none; color: rgb(12, 137, 207);">  22</a>
<a target=_blank id="L23" href="http://blog.csdn.net/linchaolong/article/details/41224483#L23" rel="#L23" style="text-decoration: none; color: rgb(12, 137, 207);">  23</a>
<a target=_blank id="L24" href="http://blog.csdn.net/linchaolong/article/details/41224483#L24" rel="#L24" style="text-decoration: none; color: rgb(12, 137, 207);">  24</a>
<a target=_blank id="L25" href="http://blog.csdn.net/linchaolong/article/details/41224483#L25" rel="#L25" style="text-decoration: none; color: rgb(12, 137, 207);">  25</a>
<a target=_blank id="L26" href="http://blog.csdn.net/linchaolong/article/details/41224483#L26" rel="#L26" style="text-decoration: none; color: rgb(12, 137, 207);">  26</a>
<a target=_blank id="L27" href="http://blog.csdn.net/linchaolong/article/details/41224483#L27" rel="#L27" style="text-decoration: none; color: rgb(12, 137, 207);">  27</a>
<a target=_blank id="L28" href="http://blog.csdn.net/linchaolong/article/details/41224483#L28" rel="#L28" style="text-decoration: none; color: rgb(12, 137, 207);">  28</a>
<a target=_blank id="L29" href="http://blog.csdn.net/linchaolong/article/details/41224483#L29" rel="#L29" style="text-decoration: none; color: rgb(12, 137, 207);">  29</a>
<a target=_blank id="L30" href="http://blog.csdn.net/linchaolong/article/details/41224483#L30" rel="#L30" style="text-decoration: none; color: rgb(12, 137, 207);">  30</a>
<a target=_blank id="L31" href="http://blog.csdn.net/linchaolong/article/details/41224483#L31" rel="#L31" style="text-decoration: none; color: rgb(12, 137, 207);">  31</a>
<a target=_blank id="L32" href="http://blog.csdn.net/linchaolong/article/details/41224483#L32" rel="#L32" style="text-decoration: none; color: rgb(12, 137, 207);">  32</a>
<a target=_blank id="L33" href="http://blog.csdn.net/linchaolong/article/details/41224483#L33" rel="#L33" style="text-decoration: none; color: rgb(12, 137, 207);">  33</a>
<a target=_blank id="L34" href="http://blog.csdn.net/linchaolong/article/details/41224483#L34" rel="#L34" style="text-decoration: none; color: rgb(12, 137, 207);">  34</a>
<a target=_blank id="L35" href="http://blog.csdn.net/linchaolong/article/details/41224483#L35" rel="#L35" style="text-decoration: none; color: rgb(12, 137, 207);">  35</a>
<a target=_blank id="L36" href="http://blog.csdn.net/linchaolong/article/details/41224483#L36" rel="#L36" style="text-decoration: none; color: rgb(12, 137, 207);">  36</a>
<a target=_blank id="L37" href="http://blog.csdn.net/linchaolong/article/details/41224483#L37" rel="#L37" style="text-decoration: none; color: rgb(12, 137, 207);">  37</a>
<a target=_blank id="L38" href="http://blog.csdn.net/linchaolong/article/details/41224483#L38" rel="#L38" style="text-decoration: none; color: rgb(12, 137, 207);">  38</a>
<a target=_blank id="L39" href="http://blog.csdn.net/linchaolong/article/details/41224483#L39" rel="#L39" style="text-decoration: none; color: rgb(12, 137, 207);">  39</a>
<a target=_blank id="L40" href="http://blog.csdn.net/linchaolong/article/details/41224483#L40" rel="#L40" style="text-decoration: none; color: rgb(12, 137, 207);">  40</a>
<a target=_blank id="L41" href="http://blog.csdn.net/linchaolong/article/details/41224483#L41" rel="#L41" style="text-decoration: none; color: rgb(12, 137, 207);">  41</a>
<a target=_blank id="L42" href="http://blog.csdn.net/linchaolong/article/details/41224483#L42" rel="#L42" style="text-decoration: none; color: rgb(12, 137, 207);">  42</a>
<a target=_blank id="L43" href="http://blog.csdn.net/linchaolong/article/details/41224483#L43" rel="#L43" style="text-decoration: none; color: rgb(12, 137, 207);">  43</a>
<a target=_blank id="L44" href="http://blog.csdn.net/linchaolong/article/details/41224483#L44" rel="#L44" style="text-decoration: none; color: rgb(12, 137, 207);">  44</a>
<a target=_blank id="L45" href="http://blog.csdn.net/linchaolong/article/details/41224483#L45" rel="#L45" style="text-decoration: none; color: rgb(12, 137, 207);">  45</a>
<a target=_blank id="L46" href="http://blog.csdn.net/linchaolong/article/details/41224483#L46" rel="#L46" style="text-decoration: none; color: rgb(12, 137, 207);">  46</a>
<a target=_blank id="L47" href="http://blog.csdn.net/linchaolong/article/details/41224483#L47" rel="#L47" style="text-decoration: none; color: rgb(12, 137, 207);">  47</a>
<a target=_blank id="L48" href="http://blog.csdn.net/linchaolong/article/details/41224483#L48" rel="#L48" style="text-decoration: none; color: rgb(12, 137, 207);">  48</a>
<a target=_blank id="L49" href="http://blog.csdn.net/linchaolong/article/details/41224483#L49" rel="#L49" style="text-decoration: none; color: rgb(12, 137, 207);">  49</a>
<a target=_blank id="L50" href="http://blog.csdn.net/linchaolong/article/details/41224483#L50" rel="#L50" style="text-decoration: none; color: rgb(12, 137, 207);">  50</a>
<a target=_blank id="L51" href="http://blog.csdn.net/linchaolong/article/details/41224483#L51" rel="#L51" style="text-decoration: none; color: rgb(12, 137, 207);">  51</a>
<a target=_blank id="L52" href="http://blog.csdn.net/linchaolong/article/details/41224483#L52" rel="#L52" style="text-decoration: none; color: rgb(12, 137, 207);">  52</a>
<a target=_blank id="L53" href="http://blog.csdn.net/linchaolong/article/details/41224483#L53" rel="#L53" style="text-decoration: none; color: rgb(12, 137, 207);">  53</a>
<a target=_blank id="L54" href="http://blog.csdn.net/linchaolong/article/details/41224483#L54" rel="#L54" style="text-decoration: none; color: rgb(12, 137, 207);">  54</a>
<a target=_blank id="L55" href="http://blog.csdn.net/linchaolong/article/details/41224483#L55" rel="#L55" style="text-decoration: none; color: rgb(12, 137, 207);">  55</a>
<a target=_blank id="L56" href="http://blog.csdn.net/linchaolong/article/details/41224483#L56" rel="#L56" style="text-decoration: none; color: rgb(12, 137, 207);">  56</a>
<a target=_blank id="L57" href="http://blog.csdn.net/linchaolong/article/details/41224483#L57" rel="#L57" style="text-decoration: none; color: rgb(12, 137, 207);">  57</a>
<a target=_blank id="L58" href="http://blog.csdn.net/linchaolong/article/details/41224483#L58" rel="#L58" style="text-decoration: none; color: rgb(12, 137, 207);">  58</a>
<a target=_blank id="L59" href="http://blog.csdn.net/linchaolong/article/details/41224483#L59" rel="#L59" style="text-decoration: none; color: rgb(12, 137, 207);">  59</a>
<a target=_blank id="L60" href="http://blog.csdn.net/linchaolong/article/details/41224483#L60" rel="#L60" style="text-decoration: none; color: rgb(12, 137, 207);">  60</a>
<a target=_blank id="L61" href="http://blog.csdn.net/linchaolong/article/details/41224483#L61" rel="#L61" style="text-decoration: none; color: rgb(12, 137, 207);">  61</a>
<a target=_blank id="L62" href="http://blog.csdn.net/linchaolong/article/details/41224483#L62" rel="#L62" style="text-decoration: none; color: rgb(12, 137, 207);">  62</a>
<a target=_blank id="L63" href="http://blog.csdn.net/linchaolong/article/details/41224483#L63" rel="#L63" style="text-decoration: none; color: rgb(12, 137, 207);">  63</a>
<a target=_blank id="L64" href="http://blog.csdn.net/linchaolong/article/details/41224483#L64" rel="#L64" style="text-decoration: none; color: rgb(12, 137, 207);">  64</a>
<a target=_blank id="L65" href="http://blog.csdn.net/linchaolong/article/details/41224483#L65" rel="#L65" style="text-decoration: none; color: rgb(12, 137, 207);">  65</a>
<a target=_blank id="L66" href="http://blog.csdn.net/linchaolong/article/details/41224483#L66" rel="#L66" style="text-decoration: none; color: rgb(12, 137, 207);">  66</a>
<a target=_blank id="L67" href="http://blog.csdn.net/linchaolong/article/details/41224483#L67" rel="#L67" style="text-decoration: none; color: rgb(12, 137, 207);">  67</a>
<a target=_blank id="L68" href="http://blog.csdn.net/linchaolong/article/details/41224483#L68" rel="#L68" style="text-decoration: none; color: rgb(12, 137, 207);">  68</a>
<a target=_blank id="L69" href="http://blog.csdn.net/linchaolong/article/details/41224483#L69" rel="#L69" style="text-decoration: none; color: rgb(12, 137, 207);">  69</a>
<a target=_blank id="L70" href="http://blog.csdn.net/linchaolong/article/details/41224483#L70" rel="#L70" style="text-decoration: none; color: rgb(12, 137, 207);">  70</a>
<a target=_blank id="L71" href="http://blog.csdn.net/linchaolong/article/details/41224483#L71" rel="#L71" style="text-decoration: none; color: rgb(12, 137, 207);">  71</a>
<a target=_blank id="L72" href="http://blog.csdn.net/linchaolong/article/details/41224483#L72" rel="#L72" style="text-decoration: none; color: rgb(12, 137, 207);">  72</a>
<a target=_blank id="L73" href="http://blog.csdn.net/linchaolong/article/details/41224483#L73" rel="#L73" style="text-decoration: none; color: rgb(12, 137, 207);">  73</a>
<a target=_blank id="L74" href="http://blog.csdn.net/linchaolong/article/details/41224483#L74" rel="#L74" style="text-decoration: none; color: rgb(12, 137, 207);">  74</a>
<a target=_blank id="L75" href="http://blog.csdn.net/linchaolong/article/details/41224483#L75" rel="#L75" style="text-decoration: none; color: rgb(12, 137, 207);">  75</a>
<a target=_blank id="L76" href="http://blog.csdn.net/linchaolong/article/details/41224483#L76" rel="#L76" style="text-decoration: none; color: rgb(12, 137, 207);">  76</a>
<a target=_blank id="L77" href="http://blog.csdn.net/linchaolong/article/details/41224483#L77" rel="#L77" style="text-decoration: none; color: rgb(12, 137, 207);">  77</a>
<a target=_blank id="L78" href="http://blog.csdn.net/linchaolong/article/details/41224483#L78" rel="#L78" style="text-decoration: none; color: rgb(12, 137, 207);">  78</a>
<a target=_blank id="L79" href="http://blog.csdn.net/linchaolong/article/details/41224483#L79" rel="#L79" style="text-decoration: none; color: rgb(12, 137, 207);">  79</a>
<a target=_blank id="L80" href="http://blog.csdn.net/linchaolong/article/details/41224483#L80" rel="#L80" style="text-decoration: none; color: rgb(12, 137, 207);">  80</a>
<a target=_blank id="L81" href="http://blog.csdn.net/linchaolong/article/details/41224483#L81" rel="#L81" style="text-decoration: none; color: rgb(12, 137, 207);">  81</a>
<a target=_blank id="L82" href="http://blog.csdn.net/linchaolong/article/details/41224483#L82" rel="#L82" style="text-decoration: none; color: rgb(12, 137, 207);">  82</a>
<a target=_blank id="L83" href="http://blog.csdn.net/linchaolong/article/details/41224483#L83" rel="#L83" style="text-decoration: none; color: rgb(12, 137, 207);">  83</a>
<a target=_blank id="L84" href="http://blog.csdn.net/linchaolong/article/details/41224483#L84" rel="#L84" style="text-decoration: none; color: rgb(12, 137, 207);">  84</a>
<a target=_blank id="L85" href="http://blog.csdn.net/linchaolong/article/details/41224483#L85" rel="#L85" style="text-decoration: none; color: rgb(12, 137, 207);">  85</a>
<a target=_blank id="L86" href="http://blog.csdn.net/linchaolong/article/details/41224483#L86" rel="#L86" style="text-decoration: none; color: rgb(12, 137, 207);">  86</a>
<a target=_blank id="L87" href="http://blog.csdn.net/linchaolong/article/details/41224483#L87" rel="#L87" style="text-decoration: none; color: rgb(12, 137, 207);">  87</a>
<a target=_blank id="L88" href="http://blog.csdn.net/linchaolong/article/details/41224483#L88" rel="#L88" style="text-decoration: none; color: rgb(12, 137, 207);">  88</a>
<a target=_blank id="L89" href="http://blog.csdn.net/linchaolong/article/details/41224483#L89" rel="#L89" style="text-decoration: none; color: rgb(12, 137, 207);">  89</a>
<a target=_blank id="L90" href="http://blog.csdn.net/linchaolong/article/details/41224483#L90" rel="#L90" style="text-decoration: none; color: rgb(12, 137, 207);">  90</a>
<a target=_blank id="L91" href="http://blog.csdn.net/linchaolong/article/details/41224483#L91" rel="#L91" style="text-decoration: none; color: rgb(12, 137, 207);">  91</a>
<a target=_blank id="L92" href="http://blog.csdn.net/linchaolong/article/details/41224483#L92" rel="#L92" style="text-decoration: none; color: rgb(12, 137, 207);">  92</a>
<a target=_blank id="L93" href="http://blog.csdn.net/linchaolong/article/details/41224483#L93" rel="#L93" style="text-decoration: none; color: rgb(12, 137, 207);">  93</a>
<a target=_blank id="L94" href="http://blog.csdn.net/linchaolong/article/details/41224483#L94" rel="#L94" style="text-decoration: none; color: rgb(12, 137, 207);">  94</a>
<a target=_blank id="L95" href="http://blog.csdn.net/linchaolong/article/details/41224483#L95" rel="#L95" style="text-decoration: none; color: rgb(12, 137, 207);">  95</a>
<a target=_blank id="L96" href="http://blog.csdn.net/linchaolong/article/details/41224483#L96" rel="#L96" style="text-decoration: none; color: rgb(12, 137, 207);">  96</a>
<a target=_blank id="L97" href="http://blog.csdn.net/linchaolong/article/details/41224483#L97" rel="#L97" style="text-decoration: none; color: rgb(12, 137, 207);">  97</a>
<a target=_blank id="L98" href="http://blog.csdn.net/linchaolong/article/details/41224483#L98" rel="#L98" style="text-decoration: none; color: rgb(12, 137, 207);">  98</a>
<a target=_blank id="L99" href="http://blog.csdn.net/linchaolong/article/details/41224483#L99" rel="#L99" style="text-decoration: none; color: rgb(12, 137, 207);">  99</a>
<a target=_blank id="L100" href="http://blog.csdn.net/linchaolong/article/details/41224483#L100" rel="#L100" style="text-decoration: none; color: rgb(12, 137, 207);"> 100</a>
<a target=_blank id="L101" href="http://blog.csdn.net/linchaolong/article/details/41224483#L101" rel="#L101" style="text-decoration: none; color: rgb(12, 137, 207);"> 101</a>
<a target=_blank id="L102" href="http://blog.csdn.net/linchaolong/article/details/41224483#L102" rel="#L102" style="text-decoration: none; color: rgb(12, 137, 207);"> 102</a>
<a target=_blank id="L103" href="http://blog.csdn.net/linchaolong/article/details/41224483#L103" rel="#L103" style="text-decoration: none; color: rgb(12, 137, 207);"> 103</a>
<a target=_blank id="L104" href="http://blog.csdn.net/linchaolong/article/details/41224483#L104" rel="#L104" style="text-decoration: none; color: rgb(12, 137, 207);"> 104</a>
<a target=_blank id="L105" href="http://blog.csdn.net/linchaolong/article/details/41224483#L105" rel="#L105" style="text-decoration: none; color: rgb(12, 137, 207);"> 105</a>
<a target=_blank id="L106" href="http://blog.csdn.net/linchaolong/article/details/41224483#L106" rel="#L106" style="text-decoration: none; color: rgb(12, 137, 207);"> 106</a>
<a target=_blank id="L107" href="http://blog.csdn.net/linchaolong/article/details/41224483#L107" rel="#L107" style="text-decoration: none; color: rgb(12, 137, 207);"> 107</a>
<a target=_blank id="L108" href="http://blog.csdn.net/linchaolong/article/details/41224483#L108" rel="#L108" style="text-decoration: none; color: rgb(12, 137, 207);"> 108</a>
<a target=_blank id="L109" href="http://blog.csdn.net/linchaolong/article/details/41224483#L109" rel="#L109" style="text-decoration: none; color: rgb(12, 137, 207);"> 109</a>
<a target=_blank id="L110" href="http://blog.csdn.net/linchaolong/article/details/41224483#L110" rel="#L110" style="text-decoration: none; color: rgb(12, 137, 207);"> 110</a>
<a target=_blank id="L111" href="http://blog.csdn.net/linchaolong/article/details/41224483#L111" rel="#L111" style="text-decoration: none; color: rgb(12, 137, 207);"> 111</a>
<a target=_blank id="L112" href="http://blog.csdn.net/linchaolong/article/details/41224483#L112" rel="#L112" style="text-decoration: none; color: rgb(12, 137, 207);"> 112</a>
<a target=_blank id="L113" href="http://blog.csdn.net/linchaolong/article/details/41224483#L113" rel="#L113" style="text-decoration: none; color: rgb(12, 137, 207);"> 113</a>
<a target=_blank id="L114" href="http://blog.csdn.net/linchaolong/article/details/41224483#L114" rel="#L114" style="text-decoration: none; color: rgb(12, 137, 207);"> 114</a>
<a target=_blank id="L115" href="http://blog.csdn.net/linchaolong/article/details/41224483#L115" rel="#L115" style="text-decoration: none; color: rgb(12, 137, 207);"> 115</a>
<a target=_blank id="L116" href="http://blog.csdn.net/linchaolong/article/details/41224483#L116" rel="#L116" style="text-decoration: none; color: rgb(12, 137, 207);"> 116</a>
<a target=_blank id="L117" href="http://blog.csdn.net/linchaolong/article/details/41224483#L117" rel="#L117" style="text-decoration: none; color: rgb(12, 137, 207);"> 117</a>
<a target=_blank id="L118" href="http://blog.csdn.net/linchaolong/article/details/41224483#L118" rel="#L118" style="text-decoration: none; color: rgb(12, 137, 207);"> 118</a>
<a target=_blank id="L119" href="http://blog.csdn.net/linchaolong/article/details/41224483#L119" rel="#L119" style="text-decoration: none; color: rgb(12, 137, 207);"> 119</a>
<a target=_blank id="L120" href="http://blog.csdn.net/linchaolong/article/details/41224483#L120" rel="#L120" style="text-decoration: none; color: rgb(12, 137, 207);"> 120</a>
<a target=_blank id="L121" href="http://blog.csdn.net/linchaolong/article/details/41224483#L121" rel="#L121" style="text-decoration: none; color: rgb(12, 137, 207);"> 121</a>
<a target=_blank id="L122" href="http://blog.csdn.net/linchaolong/article/details/41224483#L122" rel="#L122" style="text-decoration: none; color: rgb(12, 137, 207);"> 122</a>
<a target=_blank id="L123" href="http://blog.csdn.net/linchaolong/article/details/41224483#L123" rel="#L123" style="text-decoration: none; color: rgb(12, 137, 207);"> 123</a>
<a target=_blank id="L124" href="http://blog.csdn.net/linchaolong/article/details/41224483#L124" rel="#L124" style="text-decoration: none; color: rgb(12, 137, 207);"> 124</a>
<a target=_blank id="L125" href="http://blog.csdn.net/linchaolong/article/details/41224483#L125" rel="#L125" style="text-decoration: none; color: rgb(12, 137, 207);"> 125</a>
<a target=_blank id="L126" href="http://blog.csdn.net/linchaolong/article/details/41224483#L126" rel="#L126" style="text-decoration: none; color: rgb(12, 137, 207);"> 126</a>
<a target=_blank id="L127" href="http://blog.csdn.net/linchaolong/article/details/41224483#L127" rel="#L127" style="text-decoration: none; color: rgb(12, 137, 207);"> 127</a>
<a target=_blank id="L128" href="http://blog.csdn.net/linchaolong/article/details/41224483#L128" rel="#L128" style="text-decoration: none; color: rgb(12, 137, 207);"> 128</a>
<a target=_blank id="L129" href="http://blog.csdn.net/linchaolong/article/details/41224483#L129" rel="#L129" style="text-decoration: none; color: rgb(12, 137, 207);"> 129</a>
<a target=_blank id="L130" href="http://blog.csdn.net/linchaolong/article/details/41224483#L130" rel="#L130" style="text-decoration: none; color: rgb(12, 137, 207);"> 130</a>
<a target=_blank id="L131" href="http://blog.csdn.net/linchaolong/article/details/41224483#L131" rel="#L131" style="text-decoration: none; color: rgb(12, 137, 207);"> 131</a>
<a target=_blank id="L132" href="http://blog.csdn.net/linchaolong/article/details/41224483#L132" rel="#L132" style="text-decoration: none; color: rgb(12, 137, 207);"> 132</a>
<a target=_blank id="L133" href="http://blog.csdn.net/linchaolong/article/details/41224483#L133" rel="#L133" style="text-decoration: none; color: rgb(12, 137, 207);"> 133</a>
<a target=_blank id="L134" href="http://blog.csdn.net/linchaolong/article/details/41224483#L134" rel="#L134" style="text-decoration: none; color: rgb(12, 137, 207);"> 134</a>
<a target=_blank id="L135" href="http://blog.csdn.net/linchaolong/article/details/41224483#L135" rel="#L135" style="text-decoration: none; color: rgb(12, 137, 207);"> 135</a>
<a target=_blank id="L136" href="http://blog.csdn.net/linchaolong/article/details/41224483#L136" rel="#L136" style="text-decoration: none; color: rgb(12, 137, 207);"> 136</a>
<a target=_blank id="L137" href="http://blog.csdn.net/linchaolong/article/details/41224483#L137" rel="#L137" style="text-decoration: none; color: rgb(12, 137, 207);"> 137</a>
<a target=_blank id="L138" href="http://blog.csdn.net/linchaolong/article/details/41224483#L138" rel="#L138" style="text-decoration: none; color: rgb(12, 137, 207);"> 138</a>
<a target=_blank id="L139" href="http://blog.csdn.net/linchaolong/article/details/41224483#L139" rel="#L139" style="text-decoration: none; color: rgb(12, 137, 207);"> 139</a>
<a target=_blank id="L140" href="http://blog.csdn.net/linchaolong/article/details/41224483#L140" rel="#L140" style="text-decoration: none; color: rgb(12, 137, 207);"> 140</a>
<a target=_blank id="L141" href="http://blog.csdn.net/linchaolong/article/details/41224483#L141" rel="#L141" style="text-decoration: none; color: rgb(12, 137, 207);"> 141</a>
<a target=_blank id="L142" href="http://blog.csdn.net/linchaolong/article/details/41224483#L142" rel="#L142" style="text-decoration: none; color: rgb(12, 137, 207);"> 142</a>
<a target=_blank id="L143" href="http://blog.csdn.net/linchaolong/article/details/41224483#L143" rel="#L143" style="text-decoration: none; color: rgb(12, 137, 207);"> 143</a>
<a target=_blank id="L144" href="http://blog.csdn.net/linchaolong/article/details/41224483#L144" rel="#L144" style="text-decoration: none; color: rgb(12, 137, 207);"> 144</a>
<a target=_blank id="L145" href="http://blog.csdn.net/linchaolong/article/details/41224483#L145" rel="#L145" style="text-decoration: none; color: rgb(12, 137, 207);"> 145</a>
<a target=_blank id="L146" href="http://blog.csdn.net/linchaolong/article/details/41224483#L146" rel="#L146" style="text-decoration: none; color: rgb(12, 137, 207);"> 146</a>
<a target=_blank id="L147" href="http://blog.csdn.net/linchaolong/article/details/41224483#L147" rel="#L147" style="text-decoration: none; color: rgb(12, 137, 207);"> 147</a>
<a target=_blank id="L148" href="http://blog.csdn.net/linchaolong/article/details/41224483#L148" rel="#L148" style="text-decoration: none; color: rgb(12, 137, 207);"> 148</a>
<a target=_blank id="L149" href="http://blog.csdn.net/linchaolong/article/details/41224483#L149" rel="#L149" style="text-decoration: none; color: rgb(12, 137, 207);"> 149</a>
<a target=_blank id="L150" href="http://blog.csdn.net/linchaolong/article/details/41224483#L150" rel="#L150" style="text-decoration: none; color: rgb(12, 137, 207);"> 150</a>
<a target=_blank id="L151" href="http://blog.csdn.net/linchaolong/article/details/41224483#L151" rel="#L151" style="text-decoration: none; color: rgb(12, 137, 207);"> 151</a>
<a target=_blank id="L152" href="http://blog.csdn.net/linchaolong/article/details/41224483#L152" rel="#L152" style="text-decoration: none; color: rgb(12, 137, 207);"> 152</a>
<a target=_blank id="L153" href="http://blog.csdn.net/linchaolong/article/details/41224483#L153" rel="#L153" style="text-decoration: none; color: rgb(12, 137, 207);"> 153</a>
<a target=_blank id="L154" href="http://blog.csdn.net/linchaolong/article/details/41224483#L154" rel="#L154" style="text-decoration: none; color: rgb(12, 137, 207);"> 154</a>
<a target=_blank id="L155" href="http://blog.csdn.net/linchaolong/article/details/41224483#L155" rel="#L155" style="text-decoration: none; color: rgb(12, 137, 207);"> 155</a>
<a target=_blank id="L156" href="http://blog.csdn.net/linchaolong/article/details/41224483#L156" rel="#L156" style="text-decoration: none; color: rgb(12, 137, 207);"> 156</a>
<a target=_blank id="L157" href="http://blog.csdn.net/linchaolong/article/details/41224483#L157" rel="#L157" style="text-decoration: none; color: rgb(12, 137, 207);"> 157</a>
<a target=_blank id="L158" href="http://blog.csdn.net/linchaolong/article/details/41224483#L158" rel="#L158" style="text-decoration: none; color: rgb(12, 137, 207);"> 158</a>
<a target=_blank id="L159" href="http://blog.csdn.net/linchaolong/article/details/41224483#L159" rel="#L159" style="text-decoration: none; color: rgb(12, 137, 207);"> 159</a>
<a target=_blank id="L160" href="http://blog.csdn.net/linchaolong/article/details/41224483#L160" rel="#L160" style="text-decoration: none; color: rgb(12, 137, 207);"> 160</a>
<a target=_blank id="L161" href="http://blog.csdn.net/linchaolong/article/details/41224483#L161" rel="#L161" style="text-decoration: none; color: rgb(12, 137, 207);"> 161</a>
<a target=_blank id="L162" href="http://blog.csdn.net/linchaolong/article/details/41224483#L162" rel="#L162" style="text-decoration: none; color: rgb(12, 137, 207);"> 162</a>
<a target=_blank id="L163" href="http://blog.csdn.net/linchaolong/article/details/41224483#L163" rel="#L163" style="text-decoration: none; color: rgb(12, 137, 207);"> 163</a>
<a target=_blank id="L164" href="http://blog.csdn.net/linchaolong/article/details/41224483#L164" rel="#L164" style="text-decoration: none; color: rgb(12, 137, 207);"> 164</a>
<a target=_blank id="L165" href="http://blog.csdn.net/linchaolong/article/details/41224483#L165" rel="#L165" style="text-decoration: none; color: rgb(12, 137, 207);"> 165</a>
<a target=_blank id="L166" href="http://blog.csdn.net/linchaolong/article/details/41224483#L166" rel="#L166" style="text-decoration: none; color: rgb(12, 137, 207);"> 166</a>
<a target=_blank id="L167" href="http://blog.csdn.net/linchaolong/article/details/41224483#L167" rel="#L167" style="text-decoration: none; color: rgb(12, 137, 207);"> 167</a>
<a target=_blank id="L168" href="http://blog.csdn.net/linchaolong/article/details/41224483#L168" rel="#L168" style="text-decoration: none; color: rgb(12, 137, 207);"> 168</a>
<a target=_blank id="L169" href="http://blog.csdn.net/linchaolong/article/details/41224483#L169" rel="#L169" style="text-decoration: none; color: rgb(12, 137, 207);"> 169</a>
<a target=_blank id="L170" href="http://blog.csdn.net/linchaolong/article/details/41224483#L170" rel="#L170" style="text-decoration: none; color: rgb(12, 137, 207);"> 170</a>
<a target=_blank id="L171" href="http://blog.csdn.net/linchaolong/article/details/41224483#L171" rel="#L171" style="text-decoration: none; color: rgb(12, 137, 207);"> 171</a>
<a target=_blank id="L172" href="http://blog.csdn.net/linchaolong/article/details/41224483#L172" rel="#L172" style="text-decoration: none; color: rgb(12, 137, 207);"> 172</a>
<a target=_blank id="L173" href="http://blog.csdn.net/linchaolong/article/details/41224483#L173" rel="#L173" style="text-decoration: none; color: rgb(12, 137, 207);"> 173</a>
<a target=_blank id="L174" href="http://blog.csdn.net/linchaolong/article/details/41224483#L174" rel="#L174" style="text-decoration: none; color: rgb(12, 137, 207);"> 174</a>
<a target=_blank id="L175" href="http://blog.csdn.net/linchaolong/article/details/41224483#L175" rel="#L175" style="text-decoration: none; color: rgb(12, 137, 207);"> 175</a>
<a target=_blank id="L176" href="http://blog.csdn.net/linchaolong/article/details/41224483#L176" rel="#L176" style="text-decoration: none; color: rgb(12, 137, 207);"> 176</a>
<a target=_blank id="L177" href="http://blog.csdn.net/linchaolong/article/details/41224483#L177" rel="#L177" style="text-decoration: none; color: rgb(12, 137, 207);"> 177</a>
<a target=_blank id="L178" href="http://blog.csdn.net/linchaolong/article/details/41224483#L178" rel="#L178" style="text-decoration: none; color: rgb(12, 137, 207);"> 178</a>
<a target=_blank id="L179" href="http://blog.csdn.net/linchaolong/article/details/41224483#L179" rel="#L179" style="text-decoration: none; color: rgb(12, 137, 207);"> 179</a>
<a target=_blank id="L180" href="http://blog.csdn.net/linchaolong/article/details/41224483#L180" rel="#L180" style="text-decoration: none; color: rgb(12, 137, 207);"> 180</a>
<a target=_blank id="L181" href="http://blog.csdn.net/linchaolong/article/details/41224483#L181" rel="#L181" style="text-decoration: none; color: rgb(12, 137, 207);"> 181</a>
<a target=_blank id="L182" href="http://blog.csdn.net/linchaolong/article/details/41224483#L182" rel="#L182" style="text-decoration: none; color: rgb(12, 137, 207);"> 182</a>
<a target=_blank id="L183" href="http://blog.csdn.net/linchaolong/article/details/41224483#L183" rel="#L183" style="text-decoration: none; color: rgb(12, 137, 207);"> 183</a>
<a target=_blank id="L184" href="http://blog.csdn.net/linchaolong/article/details/41224483#L184" rel="#L184" style="text-decoration: none; color: rgb(12, 137, 207);"> 184</a>
<a target=_blank id="L185" href="http://blog.csdn.net/linchaolong/article/details/41224483#L185" rel="#L185" style="text-decoration: none; color: rgb(12, 137, 207);"> 185</a>
<a target=_blank id="L186" href="http://blog.csdn.net/linchaolong/article/details/41224483#L186" rel="#L186" style="text-decoration: none; color: rgb(12, 137, 207);"> 186</a>
<a target=_blank id="L187" href="http://blog.csdn.net/linchaolong/article/details/41224483#L187" rel="#L187" style="text-decoration: none; color: rgb(12, 137, 207);"> 187</a>
<a target=_blank id="L188" href="http://blog.csdn.net/linchaolong/article/details/41224483#L188" rel="#L188" style="text-decoration: none; color: rgb(12, 137, 207);"> 188</a>
<a target=_blank id="L189" href="http://blog.csdn.net/linchaolong/article/details/41224483#L189" rel="#L189" style="text-decoration: none; color: rgb(12, 137, 207);"> 189</a>
<a target=_blank id="L190" href="http://blog.csdn.net/linchaolong/article/details/41224483#L190" rel="#L190" style="text-decoration: none; color: rgb(12, 137, 207);"> 190</a>
<a target=_blank id="L191" href="http://blog.csdn.net/linchaolong/article/details/41224483#L191" rel="#L191" style="text-decoration: none; color: rgb(12, 137, 207);"> 191</a>
<a target=_blank id="L192" href="http://blog.csdn.net/linchaolong/article/details/41224483#L192" rel="#L192" style="text-decoration: none; color: rgb(12, 137, 207);"> 192</a>
<a target=_blank id="L193" href="http://blog.csdn.net/linchaolong/article/details/41224483#L193" rel="#L193" style="text-decoration: none; color: rgb(12, 137, 207);"> 193</a>
<a target=_blank id="L194" href="http://blog.csdn.net/linchaolong/article/details/41224483#L194" rel="#L194" style="text-decoration: none; color: rgb(12, 137, 207);"> 194</a>
<a target=_blank id="L195" href="http://blog.csdn.net/linchaolong/article/details/41224483#L195" rel="#L195" style="text-decoration: none; color: rgb(12, 137, 207);"> 195</a>
<a target=_blank id="L196" href="http://blog.csdn.net/linchaolong/article/details/41224483#L196" rel="#L196" style="text-decoration: none; color: rgb(12, 137, 207);"> 196</a>
<a target=_blank id="L197" href="http://blog.csdn.net/linchaolong/article/details/41224483#L197" rel="#L197" style="text-decoration: none; color: rgb(12, 137, 207);"> 197</a>
<a target=_blank id="L198" href="http://blog.csdn.net/linchaolong/article/details/41224483#L198" rel="#L198" style="text-decoration: none; color: rgb(12, 137, 207);"> 198</a>
<a target=_blank id="L199" href="http://blog.csdn.net/linchaolong/article/details/41224483#L199" rel="#L199" style="text-decoration: none; color: rgb(12, 137, 207);"> 199</a>
<a target=_blank id="L200" href="http://blog.csdn.net/linchaolong/article/details/41224483#L200" rel="#L200" style="text-decoration: none; color: rgb(12, 137, 207);"> 200</a>
<a target=_blank id="L201" href="http://blog.csdn.net/linchaolong/article/details/41224483#L201" rel="#L201" style="text-decoration: none; color: rgb(12, 137, 207);"> 201</a>
<a target=_blank id="L202" href="http://blog.csdn.net/linchaolong/article/details/41224483#L202" rel="#L202" style="text-decoration: none; color: rgb(12, 137, 207);"> 202</a>
<a target=_blank id="L203" href="http://blog.csdn.net/linchaolong/article/details/41224483#L203" rel="#L203" style="text-decoration: none; color: rgb(12, 137, 207);"> 203</a>
<a target=_blank id="L204" href="http://blog.csdn.net/linchaolong/article/details/41224483#L204" rel="#L204" style="text-decoration: none; color: rgb(12, 137, 207);"> 204</a>
<a target=_blank id="L205" href="http://blog.csdn.net/linchaolong/article/details/41224483#L205" rel="#L205" style="text-decoration: none; color: rgb(12, 137, 207);"> 205</a>
<a target=_blank id="L206" href="http://blog.csdn.net/linchaolong/article/details/41224483#L206" rel="#L206" style="text-decoration: none; color: rgb(12, 137, 207);"> 206</a>
<a target=_blank id="L207" href="http://blog.csdn.net/linchaolong/article/details/41224483#L207" rel="#L207" style="text-decoration: none; color: rgb(12, 137, 207);"> 207</a>
<a target=_blank id="L208" href="http://blog.csdn.net/linchaolong/article/details/41224483#L208" rel="#L208" style="text-decoration: none; color: rgb(12, 137, 207);"> 208</a>
<a target=_blank id="L209" href="http://blog.csdn.net/linchaolong/article/details/41224483#L209" rel="#L209" style="text-decoration: none; color: rgb(12, 137, 207);"> 209</a>
            
            
/*
* base64.cpp
*
* Created on: 30/04/2011
* Author: nicholas
*/
#include "base64.h"
#include <cctype>
//#include <cstdint>
#include <algorithm>
namespace base64
{
namespace
{
static const std :: string BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ;
size_t encoded_size ( size_t raw )
{
switch (( raw * 8 ) % 6 )
{
case 0:
return ( raw * 8 ) / 6 ;
case 2:
return (( raw * 8 ) / 6 ) + 3 ;
case 4:
return (( raw * 8 ) / 6 ) + 2 ;
}
return raw ;
}
size_t decoded_size ( size_t unpadded )
{
return ( unpadded * 6 ) / 8 ;
}
int base64_index ( std :: string :: value_type c )
{
if ( c >= 'A' && c <= 'Z' )
return c - 'A' ;
else if ( c >= 'a' && c <= 'z' )
return c - 'a' + 26 ;
else if ( c >= '0' && c <= '9' )
return c - '0' + 52 ;
else if ( c == '+' )
return 62 ;
else if ( c == '/' )
return 63 ;
else
return - 1 ;
}
}
encode_t :: encode_t ( std :: string :: size_type size )
: state ( zero ), remainder ( 0 )
{
encoded . reserve ( encoded_size ( size ));
}
/*
State zero
8 bits input, zero remaining from last
6 bits consumed, 2 remaining
=> two
State two
8 bits input, 2 remaining from last
4 bits consumed, 4 remaining
=> four
State four
8 bits input, 4 remaining from last
2 bits consumed, 6 remaining
6 bits input, 6 remaining from last
6 bits consumed, 0 remaining
=> zero
*/
void encode_t :: operator () ( std :: string :: value_type c )
{
unsigned char value ( 0 );
switch ( state )
{
case zero:
value = ( c & 0xfc ) >> 2 ;
remainder = c & 0x3 ;
encoded . push_back ( BASE64_CHARS [ value ]);
state = two ;
break ;
case two:
value = ( remainder << 4 ) | (( c & 0xf0 ) >> 4 );
remainder = c & 0xf ;
encoded . push_back ( BASE64_CHARS [ value ]);
state = four ;
break ;
case four:
value = ( remainder << 2 ) | (( c & 0xc0 ) >> 6 );
remainder = c & 0x3f ;
encoded . push_back ( BASE64_CHARS [ value ]);
value = remainder ;
encoded . push_back ( BASE64_CHARS [ value ]);
state = zero ;
break ;
}
}
std :: string encode_t :: str ()
{
unsigned char value ( 0 );
switch ( state )
{
case zero:
break ;
case two:
value = remainder << 4 ;
encoded . push_back ( BASE64_CHARS [ value ]);
encoded . push_back ( '=' );
encoded . push_back ( '=' );
state = zero ;
break ;
case four:
value = remainder << 2 ;
encoded . push_back ( BASE64_CHARS [ value ]);
encoded . push_back ( '=' );
state = zero ;
break ;
}
return encoded ;
}
decode_t :: decode_t ( std :: string :: size_type size )
: state ( zero ), remainder ( 0 )
{
decoded . reserve ( decoded_size ( size ));
}
/*
State zero
6 bits input, zero remaining from last
6 bits consumed, zero remaining
=> six
State six
6 bits input, 6 remaining from last
write 1 byte, 4 remaining
=> four
State four
6 bits input, 4 remaining from last
write 1 byte, 2 remaining
=> two
State two
6 bits input, 2 remaining from last
write 1 byte, 0 remaining
=> zero
*/
void decode_t :: operator () ( std :: string :: value_type c )
{
unsigned char value ( 0 );
int index = base64_index ( c );
if ( index == - 1 )
return ;
switch ( state )
{
case zero:
remainder = index ;
state = six ;
break ;
case six:
value = ( remainder << 2 ) | (( index & 0x30 ) >> 4 );
remainder = index & 0xf ;
decoded . push_back ( value );
state = four ;
break ;
case four:
value = ( remainder << 4 ) | (( index & 0x3c ) >> 2 );
remainder = index & 0x3 ;
decoded . push_back ( value );
state = two ;
break ;
case two:
value = ( remainder << 6 ) | index ;
decoded . push_back ( value );
state = zero ;
break ;
}
}
std :: string decode_t :: str () const
{
return decoded ;
}
std :: string encode ( const std :: string & str )
{
return std :: for_each ( str . begin (), str . end (), encode_t ( str . size ())). str ();
}
std :: string decode ( const std :: string & str )
{
size_t unpadded_size = str . size ();
if ( str . size () > 0 && str [ str . size () - 1 ] == '=' )
unpadded_size -= 1 ;
if ( str . size () > 1 && str [ str . size () - 2 ] == '=' )
unpadded_size -= 1 ;
return std :: for_each ( str . begin (), str . end (), decode_t ( unpadded_size )). str ();
}
}
 来自CODE的代码片
base64.cpp
<a target=_blank id="L1" href="http://blog.csdn.net/linchaolong/article/details/41224483#L1" rel="#L1" style="text-decoration: none; color: rgb(12, 137, 207);">  1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/linchaolong/article/details/41224483#L2" rel="#L2" style="text-decoration: none; color: rgb(12, 137, 207);">  2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/linchaolong/article/details/41224483#L3" rel="#L3" style="text-decoration: none; color: rgb(12, 137, 207);">  3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/linchaolong/article/details/41224483#L4" rel="#L4" style="text-decoration: none; color: rgb(12, 137, 207);">  4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/linchaolong/article/details/41224483#L5" rel="#L5" style="text-decoration: none; color: rgb(12, 137, 207);">  5</a>
<a target=_blank id="L6" href="http://blog.csdn.net/linchaolong/article/details/41224483#L6" rel="#L6" style="text-decoration: none; color: rgb(12, 137, 207);">  6</a>
<a target=_blank id="L7" href="http://blog.csdn.net/linchaolong/article/details/41224483#L7" rel="#L7" style="text-decoration: none; color: rgb(12, 137, 207);">  7</a>
<a target=_blank id="L8" href="http://blog.csdn.net/linchaolong/article/details/41224483#L8" rel="#L8" style="text-decoration: none; color: rgb(12, 137, 207);">  8</a>
<a target=_blank id="L9" href="http://blog.csdn.net/linchaolong/article/details/41224483#L9" rel="#L9" style="text-decoration: none; color: rgb(12, 137, 207);">  9</a>
<a target=_blank id="L10" href="http://blog.csdn.net/linchaolong/article/details/41224483#L10" rel="#L10" style="text-decoration: none; color: rgb(12, 137, 207);"> 10</a>
<a target=_blank id="L11" href="http://blog.csdn.net/linchaolong/article/details/41224483#L11" rel="#L11" style="text-decoration: none; color: rgb(12, 137, 207);"> 11</a>
<a target=_blank id="L12" href="http://blog.csdn.net/linchaolong/article/details/41224483#L12" rel="#L12" style="text-decoration: none; color: rgb(12, 137, 207);"> 12</a>
<a target=_blank id="L13" href="http://blog.csdn.net/linchaolong/article/details/41224483#L13" rel="#L13" style="text-decoration: none; color: rgb(12, 137, 207);"> 13</a>
<a target=_blank id="L14" href="http://blog.csdn.net/linchaolong/article/details/41224483#L14" rel="#L14" style="text-decoration: none; color: rgb(12, 137, 207);"> 14</a>
<a target=_blank id="L15" href="http://blog.csdn.net/linchaolong/article/details/41224483#L15" rel="#L15" style="text-decoration: none; color: rgb(12, 137, 207);"> 15</a>
<a target=_blank id="L16" href="http://blog.csdn.net/linchaolong/article/details/41224483#L16" rel="#L16" style="text-decoration: none; color: rgb(12, 137, 207);"> 16</a>
<a target=_blank id="L17" href="http://blog.csdn.net/linchaolong/article/details/41224483#L17" rel="#L17" style="text-decoration: none; color: rgb(12, 137, 207);"> 17</a>
<a target=_blank id="L18" href="http://blog.csdn.net/linchaolong/article/details/41224483#L18" rel="#L18" style="text-decoration: none; color: rgb(12, 137, 207);"> 18</a>
<a target=_blank id="L19" href="http://blog.csdn.net/linchaolong/article/details/41224483#L19" rel="#L19" style="text-decoration: none; color: rgb(12, 137, 207);"> 19</a>
<a target=_blank id="L20" href="http://blog.csdn.net/linchaolong/article/details/41224483#L20" rel="#L20" style="text-decoration: none; color: rgb(12, 137, 207);"> 20</a>
<a target=_blank id="L21" href="http://blog.csdn.net/linchaolong/article/details/41224483#L21" rel="#L21" style="text-decoration: none; color: rgb(12, 137, 207);"> 21</a>
<a target=_blank id="L22" href="http://blog.csdn.net/linchaolong/article/details/41224483#L22" rel="#L22" style="text-decoration: none; color: rgb(12, 137, 207);"> 22</a>
<a target=_blank id="L23" href="http://blog.csdn.net/linchaolong/article/details/41224483#L23" rel="#L23" style="text-decoration: none; color: rgb(12, 137, 207);"> 23</a>
<a target=_blank id="L24" href="http://blog.csdn.net/linchaolong/article/details/41224483#L24" rel="#L24" style="text-decoration: none; color: rgb(12, 137, 207);"> 24</a>
<a target=_blank id="L25" href="http://blog.csdn.net/linchaolong/article/details/41224483#L25" rel="#L25" style="text-decoration: none; color: rgb(12, 137, 207);"> 25</a>
<a target=_blank id="L26" href="http://blog.csdn.net/linchaolong/article/details/41224483#L26" rel="#L26" style="text-decoration: none; color: rgb(12, 137, 207);"> 26</a>
<a target=_blank id="L27" href="http://blog.csdn.net/linchaolong/article/details/41224483#L27" rel="#L27" style="text-decoration: none; color: rgb(12, 137, 207);"> 27</a>
<a target=_blank id="L28" href="http://blog.csdn.net/linchaolong/article/details/41224483#L28" rel="#L28" style="text-decoration: none; color: rgb(12, 137, 207);"> 28</a>
<a target=_blank id="L29" href="http://blog.csdn.net/linchaolong/article/details/41224483#L29" rel="#L29" style="text-decoration: none; color: rgb(12, 137, 207);"> 29</a>
<a target=_blank id="L30" href="http://blog.csdn.net/linchaolong/article/details/41224483#L30" rel="#L30" style="text-decoration: none; color: rgb(12, 137, 207);"> 30</a>
<a target=_blank id="L31" href="http://blog.csdn.net/linchaolong/article/details/41224483#L31" rel="#L31" style="text-decoration: none; color: rgb(12, 137, 207);"> 31</a>
<a target=_blank id="L32" href="http://blog.csdn.net/linchaolong/article/details/41224483#L32" rel="#L32" style="text-decoration: none; color: rgb(12, 137, 207);"> 32</a>
<a target=_blank id="L33" href="http://blog.csdn.net/linchaolong/article/details/41224483#L33" rel="#L33" style="text-decoration: none; color: rgb(12, 137, 207);"> 33</a>
<a target=_blank id="L34" href="http://blog.csdn.net/linchaolong/article/details/41224483#L34" rel="#L34" style="text-decoration: none; color: rgb(12, 137, 207);"> 34</a>
<a target=_blank id="L35" href="http://blog.csdn.net/linchaolong/article/details/41224483#L35" rel="#L35" style="text-decoration: none; color: rgb(12, 137, 207);"> 35</a>
<a target=_blank id="L36" href="http://blog.csdn.net/linchaolong/article/details/41224483#L36" rel="#L36" style="text-decoration: none; color: rgb(12, 137, 207);"> 36</a>
<a target=_blank id="L37" href="http://blog.csdn.net/linchaolong/article/details/41224483#L37" rel="#L37" style="text-decoration: none; color: rgb(12, 137, 207);"> 37</a>
<a target=_blank id="L38" href="http://blog.csdn.net/linchaolong/article/details/41224483#L38" rel="#L38" style="text-decoration: none; color: rgb(12, 137, 207);"> 38</a>
<a target=_blank id="L39" href="http://blog.csdn.net/linchaolong/article/details/41224483#L39" rel="#L39" style="text-decoration: none; color: rgb(12, 137, 207);"> 39</a>
<a target=_blank id="L40" href="http://blog.csdn.net/linchaolong/article/details/41224483#L40" rel="#L40" style="text-decoration: none; color: rgb(12, 137, 207);"> 40</a>
<a target=_blank id="L41" href="http://blog.csdn.net/linchaolong/article/details/41224483#L41" rel="#L41" style="text-decoration: none; color: rgb(12, 137, 207);"> 41</a>
<a target=_blank id="L42" href="http://blog.csdn.net/linchaolong/article/details/41224483#L42" rel="#L42" style="text-decoration: none; color: rgb(12, 137, 207);"> 42</a>
<a target=_blank id="L43" href="http://blog.csdn.net/linchaolong/article/details/41224483#L43" rel="#L43" style="text-decoration: none; color: rgb(12, 137, 207);"> 43</a>
<a target=_blank id="L44" href="http://blog.csdn.net/linchaolong/article/details/41224483#L44" rel="#L44" style="text-decoration: none; color: rgb(12, 137, 207);"> 44</a>
<a target=_blank id="L45" href="http://blog.csdn.net/linchaolong/article/details/41224483#L45" rel="#L45" style="text-decoration: none; color: rgb(12, 137, 207);"> 45</a>
<a target=_blank id="L46" href="http://blog.csdn.net/linchaolong/article/details/41224483#L46" rel="#L46" style="text-decoration: none; color: rgb(12, 137, 207);"> 46</a>
<a target=_blank id="L47" href="http://blog.csdn.net/linchaolong/article/details/41224483#L47" rel="#L47" style="text-decoration: none; color: rgb(12, 137, 207);"> 47</a>
<a target=_blank id="L48" href="http://blog.csdn.net/linchaolong/article/details/41224483#L48" rel="#L48" style="text-decoration: none; color: rgb(12, 137, 207);"> 48</a>
<a target=_blank id="L49" href="http://blog.csdn.net/linchaolong/article/details/41224483#L49" rel="#L49" style="text-decoration: none; color: rgb(12, 137, 207);"> 49</a>
<a target=_blank id="L50" href="http://blog.csdn.net/linchaolong/article/details/41224483#L50" rel="#L50" style="text-decoration: none; color: rgb(12, 137, 207);"> 50</a>
<a target=_blank id="L51" href="http://blog.csdn.net/linchaolong/article/details/41224483#L51" rel="#L51" style="text-decoration: none; color: rgb(12, 137, 207);"> 51</a>
<a target=_blank id="L52" href="http://blog.csdn.net/linchaolong/article/details/41224483#L52" rel="#L52" style="text-decoration: none; color: rgb(12, 137, 207);"> 52</a>
<a target=_blank id="L53" href="http://blog.csdn.net/linchaolong/article/details/41224483#L53" rel="#L53" style="text-decoration: none; color: rgb(12, 137, 207);"> 53</a>
<a target=_blank id="L54" href="http://blog.csdn.net/linchaolong/article/details/41224483#L54" rel="#L54" style="text-decoration: none; color: rgb(12, 137, 207);"> 54</a>
<a target=_blank id="L55" href="http://blog.csdn.net/linchaolong/article/details/41224483#L55" rel="#L55" style="text-decoration: none; color: rgb(12, 137, 207);"> 55</a>
<a target=_blank id="L56" href="http://blog.csdn.net/linchaolong/article/details/41224483#L56" rel="#L56" style="text-decoration: none; color: rgb(12, 137, 207);"> 56</a>
<a target=_blank id="L57" href="http://blog.csdn.net/linchaolong/article/details/41224483#L57" rel="#L57" style="text-decoration: none; color: rgb(12, 137, 207);"> 57</a>
<a target=_blank id="L58" href="http://blog.csdn.net/linchaolong/article/details/41224483#L58" rel="#L58" style="text-decoration: none; color: rgb(12, 137, 207);"> 58</a>
<a target=_blank id="L59" href="http://blog.csdn.net/linchaolong/article/details/41224483#L59" rel="#L59" style="text-decoration: none; color: rgb(12, 137, 207);"> 59</a>
<a target=_blank id="L60" href="http://blog.csdn.net/linchaolong/article/details/41224483#L60" rel="#L60" style="text-decoration: none; color: rgb(12, 137, 207);"> 60</a>
<a target=_blank id="L61" href="http://blog.csdn.net/linchaolong/article/details/41224483#L61" rel="#L61" style="text-decoration: none; color: rgb(12, 137, 207);"> 61</a>
<a target=_blank id="L62" href="http://blog.csdn.net/linchaolong/article/details/41224483#L62" rel="#L62" style="text-decoration: none; color: rgb(12, 137, 207);"> 62</a>
            
            
/*
* base64.h
*
* Created on: 30/04/2011
* Author: nicholas
*/
#ifndef BASE64_H_
#define BASE64_H_
#include <string>
namespace base64
{
class encode_t
{
private:
enum
{
zero = 0 ,
two ,
four
} state ;
unsigned int remainder ;
std :: string encoded ;
public:
encode_t ( std :: string :: size_type size );
void operator () ( std :: string :: value_type c );
std :: string str ();
};
class decode_t
{
private:
enum
{
zero = 0 ,
six ,
four ,
two
} state ;
unsigned int remainder ;
std :: string decoded ;
public:
decode_t ( std :: string :: size_type size );
void operator () ( std :: string :: value_type c );
std :: string str () const ;
};
/*
* Encode the given string @str into its base64 representation
*/
std :: string encode ( const std :: string & str );
/*
* Decode the base64 encoded string @str
*/
std :: string decode ( const std :: string & str );
}
#endif /* BASE64_H_ */
 来自CODE的代码片
base64.h
<a target=_blank id="L1" href="http://blog.csdn.net/linchaolong/article/details/41224483#L1" rel="#L1" style="text-decoration: none; color: rgb(12, 137, 207);">  1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/linchaolong/article/details/41224483#L2" rel="#L2" style="text-decoration: none; color: rgb(12, 137, 207);">  2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/linchaolong/article/details/41224483#L3" rel="#L3" style="text-decoration: none; color: rgb(12, 137, 207);">  3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/linchaolong/article/details/41224483#L4" rel="#L4" style="text-decoration: none; color: rgb(12, 137, 207);">  4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/linchaolong/article/details/41224483#L5" rel="#L5" style="text-decoration: none; color: rgb(12, 137, 207);">  5</a>
<a target=_blank id="L6" href="http://blog.csdn.net/linchaolong/article/details/41224483#L6" rel="#L6" style="text-decoration: none; color: rgb(12, 137, 207);">  6</a>
<a target=_blank id="L7" href="http://blog.csdn.net/linchaolong/article/details/41224483#L7" rel="#L7" style="text-decoration: none; color: rgb(12, 137, 207);">  7</a>
<a target=_blank id="L8" href="http://blog.csdn.net/linchaolong/article/details/41224483#L8" rel="#L8" style="text-decoration: none; color: rgb(12, 137, 207);">  8</a>
<a target=_blank id="L9" href="http://blog.csdn.net/linchaolong/article/details/41224483#L9" rel="#L9" style="text-decoration: none; color: rgb(12, 137, 207);">  9</a>
<a target=_blank id="L10" href="http://blog.csdn.net/linchaolong/article/details/41224483#L10" rel="#L10" style="text-decoration: none; color: rgb(12, 137, 207);"> 10</a>
<a target=_blank id="L11" href="http://blog.csdn.net/linchaolong/article/details/41224483#L11" rel="#L11" style="text-decoration: none; color: rgb(12, 137, 207);"> 11</a>
<a target=_blank id="L12" href="http://blog.csdn.net/linchaolong/article/details/41224483#L12" rel="#L12" style="text-decoration: none; color: rgb(12, 137, 207);"> 12</a>
<a target=_blank id="L13" href="http://blog.csdn.net/linchaolong/article/details/41224483#L13" rel="#L13" style="text-decoration: none; color: rgb(12, 137, 207);"> 13</a>
<a target=_blank id="L14" href="http://blog.csdn.net/linchaolong/article/details/41224483#L14" rel="#L14" style="text-decoration: none; color: rgb(12, 137, 207);"> 14</a>
<a target=_blank id="L15" href="http://blog.csdn.net/linchaolong/article/details/41224483#L15" rel="#L15" style="text-decoration: none; color: rgb(12, 137, 207);"> 15</a>
<a target=_blank id="L16" href="http://blog.csdn.net/linchaolong/article/details/41224483#L16" rel="#L16" style="text-decoration: none; color: rgb(12, 137, 207);"> 16</a>
<a target=_blank id="L17" href="http://blog.csdn.net/linchaolong/article/details/41224483#L17" rel="#L17" style="text-decoration: none; color: rgb(12, 137, 207);"> 17</a>
<a target=_blank id="L18" href="http://blog.csdn.net/linchaolong/article/details/41224483#L18" rel="#L18" style="text-decoration: none; color: rgb(12, 137, 207);"> 18</a>
<a target=_blank id="L19" href="http://blog.csdn.net/linchaolong/article/details/41224483#L19" rel="#L19" style="text-decoration: none; color: rgb(12, 137, 207);"> 19</a>
<a target=_blank id="L20" href="http://blog.csdn.net/linchaolong/article/details/41224483#L20" rel="#L20" style="text-decoration: none; color: rgb(12, 137, 207);"> 20</a>
<a target=_blank id="L21" href="http://blog.csdn.net/linchaolong/article/details/41224483#L21" rel="#L21" style="text-decoration: none; color: rgb(12, 137, 207);"> 21</a>
<a target=_blank id="L22" href="http://blog.csdn.net/linchaolong/article/details/41224483#L22" rel="#L22" style="text-decoration: none; color: rgb(12, 137, 207);"> 22</a>
<a target=_blank id="L23" href="http://blog.csdn.net/linchaolong/article/details/41224483#L23" rel="#L23" style="text-decoration: none; color: rgb(12, 137, 207);"> 23</a>
            
            
#include<iostream>
#include"base64.h"
using namespace std ;
int main ()
{
string str = "abcdefghijklmn." ;
string out = base64 :: encode ( str );
cout << "src:" << str << endl ;
cout << "encode: " << out << endl ;
cout << "decode: " << base64 :: decode ( out ) << endl ;
str = "中文." ;
out = base64 :: encode ( str );
cout << endl << "src:" << str << endl ;
cout << "encode: " << out << endl ;
cout << "decode: " << base64 :: decode ( out ) << endl ;
system ( "pause" );
return 1 ;
}
 来自CODE的代码片
main.cpp



Android平台下使用Base64算法加密解密数据


<a target=_blank id="L1" href="http://blog.csdn.net/linchaolong/article/details/41224483#L1" rel="#L1" style="text-decoration: none; color: rgb(12, 137, 207);">  1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/linchaolong/article/details/41224483#L2" rel="#L2" style="text-decoration: none; color: rgb(12, 137, 207);">  2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/linchaolong/article/details/41224483#L3" rel="#L3" style="text-decoration: none; color: rgb(12, 137, 207);">  3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/linchaolong/article/details/41224483#L4" rel="#L4" style="text-decoration: none; color: rgb(12, 137, 207);">  4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/linchaolong/article/details/41224483#L5" rel="#L5" style="text-decoration: none; color: rgb(12, 137, 207);">  5</a>
<a target=_blank id="L6" href="http://blog.csdn.net/linchaolong/article/details/41224483#L6" rel="#L6" style="text-decoration: none; color: rgb(12, 137, 207);">  6</a>
<a target=_blank id="L7" href="http://blog.csdn.net/linchaolong/article/details/41224483#L7" rel="#L7" style="text-decoration: none; color: rgb(12, 137, 207);">  7</a>
<a target=_blank id="L8" href="http://blog.csdn.net/linchaolong/article/details/41224483#L8" rel="#L8" style="text-decoration: none; color: rgb(12, 137, 207);">  8</a>
<a target=_blank id="L9" href="http://blog.csdn.net/linchaolong/article/details/41224483#L9" rel="#L9" style="text-decoration: none; color: rgb(12, 137, 207);">  9</a>
<a target=_blank id="L10" href="http://blog.csdn.net/linchaolong/article/details/41224483#L10" rel="#L10" style="text-decoration: none; color: rgb(12, 137, 207);"> 10</a>
<a target=_blank id="L11" href="http://blog.csdn.net/linchaolong/article/details/41224483#L11" rel="#L11" style="text-decoration: none; color: rgb(12, 137, 207);"> 11</a>
<a target=_blank id="L12" href="http://blog.csdn.net/linchaolong/article/details/41224483#L12" rel="#L12" style="text-decoration: none; color: rgb(12, 137, 207);"> 12</a>
<a target=_blank id="L13" href="http://blog.csdn.net/linchaolong/article/details/41224483#L13" rel="#L13" style="text-decoration: none; color: rgb(12, 137, 207);"> 13</a>
<a target=_blank id="L14" href="http://blog.csdn.net/linchaolong/article/details/41224483#L14" rel="#L14" style="text-decoration: none; color: rgb(12, 137, 207);"> 14</a>
<a target=_blank id="L15" href="http://blog.csdn.net/linchaolong/article/details/41224483#L15" rel="#L15" style="text-decoration: none; color: rgb(12, 137, 207);"> 15</a>
<a target=_blank id="L16" href="http://blog.csdn.net/linchaolong/article/details/41224483#L16" rel="#L16" style="text-decoration: none; color: rgb(12, 137, 207);"> 16</a>
<a target=_blank id="L17" href="http://blog.csdn.net/linchaolong/article/details/41224483#L17" rel="#L17" style="text-decoration: none; color: rgb(12, 137, 207);"> 17</a>
<a target=_blank id="L18" href="http://blog.csdn.net/linchaolong/article/details/41224483#L18" rel="#L18" style="text-decoration: none; color: rgb(12, 137, 207);"> 18</a>
<a target=_blank id="L19" href="http://blog.csdn.net/linchaolong/article/details/41224483#L19" rel="#L19" style="text-decoration: none; color: rgb(12, 137, 207);"> 19</a>
<a target=_blank id="L20" href="http://blog.csdn.net/linchaolong/article/details/41224483#L20" rel="#L20" style="text-decoration: none; color: rgb(12, 137, 207);"> 20</a>
<a target=_blank id="L21" href="http://blog.csdn.net/linchaolong/article/details/41224483#L21" rel="#L21" style="text-decoration: none; color: rgb(12, 137, 207);"> 21</a>
<a target=_blank id="L22" href="http://blog.csdn.net/linchaolong/article/details/41224483#L22" rel="#L22" style="text-decoration: none; color: rgb(12, 137, 207);"> 22</a>
<a target=_blank id="L23" href="http://blog.csdn.net/linchaolong/article/details/41224483#L23" rel="#L23" style="text-decoration: none; color: rgb(12, 137, 207);"> 23</a>
             
             
import com.example.base64.R ;
import android.app.Activity ;
import android.os.Bundle ;
import android.util.Base64 ;
public class MainActivity extends Activity {
@Override
protected void onCreate ( Bundle savedInstanceState ) {
super . onCreate ( savedInstanceState );
setContentView ( R . layout . main );
String src = "abcdefjhijklmn." ;
// 加密数据
String encode = Base64 . encodeToString ( src . getBytes (), Base64 . DEFAULT );
// 解密数据
String decode = new String ( Base64 . decode ( encode , Base64 . DEFAULT ));
System . out . println ( "src:" + src );
System . out . println ( "encode:" + encode );
System . out . println ( "decode:" + decode );
}
}
 来自CODE的代码片
MainActivity.java




数据库数据项加密


cocos2d-x中操作数据库的实现都封装在LocalStorage这个类中。使用的是sqlite3。

IOS、Win32平台的加密


1.base64.h和base64.cpp添加项目Classes目录下。


2.右键libExtensions项目,附加包含目录,把base64库所在目录添加到包含目录中,具体路径根据自己项目结构而定



3.修改localStorageSetItem方法,保存数据时加密数据,这里在win32平台下忽略加密操作是因为一般win32平台版本是用于内部测试的

[cpp]  view plain copy
  1. void localStorageSetItem( const char *key, const char *value)  
  2. {  
  3.     assert( _initialized );  
  4.   
  5.     // 加密数据  
  6.     #if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)  
  7.         //CCLOG("key=%s src=%s", key, value);         
  8.         std::string encodeStr = base64::encode(value);  
  9.         value = encodeStr.c_str();  
  10.         //CCLOG("key=%s encode=%s", key, value);  
  11.     #endif  
  12.       
  13.     int ok = sqlite3_bind_text(_stmt_update, 1, key, -1, SQLITE_TRANSIENT);  
  14.     ok |= sqlite3_bind_text(_stmt_update, 2, value, -1, SQLITE_TRANSIENT);  
  15.   
  16.     ok |= sqlite3_step(_stmt_update);  
  17.       
  18.     ok |= sqlite3_reset(_stmt_update);  
  19.       
  20.     if( ok != SQLITE_OK && ok != SQLITE_DONE)  
  21.         printf("Error in localStorage.setItem()\n");  
  22. }  

4.修改localStorageGetItem方法,获取数据时解密数据

[cpp]  view plain copy
  1. const char* localStorageGetItem( const char *key )  
  2. {  
  3.     assert( _initialized );  
  4.   
  5.     int ok = sqlite3_reset(_stmt_select);  
  6.   
  7.     ok |= sqlite3_bind_text(_stmt_select, 1, key, -1, SQLITE_TRANSIENT);  
  8.     ok |= sqlite3_step(_stmt_select);  
  9.     const unsigned char *ret = sqlite3_column_text(_stmt_select, 0);  
  10.       
  11.   
  12.     if( ok != SQLITE_OK && ok != SQLITE_DONE && ok != SQLITE_ROW)  
  13.         printf("Error in localStorage.getItem()\n");  
  14.   
  15.     // 加密数据  
  16.     #if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)  
  17.         //CCLOG("decode src=%s", ret);    
  18.         if (ret)  
  19.         {  
  20.             std::string decodeStr = base64::decode((const char*)ret);                         
  21.               
  22.             char* c = new char;               
  23.             strcpy_s(c, decodeStr.size() + 1, decodeStr.c_str());    
  24.             //CCLOG("key=%s decode=%s", key, c);              
  25.             return c;  
  26.         }         
  27.     #endif  
  28.   
  29.     return (const char*)ret;  
  30. }  


注意:c_str()方法返回的是string对象中保留的字符串指针,该指针的生命周期是跟随string对象的。也就是如果直接返回decodeStr.c_str(),返回的将是垃圾数据,因为decodeStr在函数结束后,已经被销毁了,指针所指向的是垃圾数据。


这种数据库加密方案存在以下几个问题:

1.如果别人知道我所使用的加密算法,然后通过程序计算出加密串,还是可以修改成功的。

2.数据库还是可以用相关工具打开,并查看数据表。

3.每次读写数据时,增加了加密解密的步骤,降低效率。


对于Cocos2d-x中数据库的加密有更好的解决办法,就是使用wxsqlite3,点击查看【集成wxSqlite3到Cocos2d-x】,这种数据库加密的实现是在初始化数据库的时候加密,运行时加载数据库时候调用相关api解密,加载完成后数据的读写效率和未加密时一样,相对比较高效。



Android平台的加密


从LocalStorage.cpp中使用的宏可以看出,这个实现在安卓平台下是无法使用的



安卓平台下的实现在:cocos2d-x-2.1.5\extensions\LocalStorage目录下的LocalStorageAndroid.cpp中。

从localStrorageInit的实现可以看出,它是通过jni调用了java层中org/cocos2dx/lib/Cocos2dxLocalStorage的静态方法init



在打包安卓版Cocos2d-x游戏时需要用到引擎的一个java库,在cocos2d-x-2.1.5\cocos2dx\platform\android\java目录下,Cocos2dxLocalStorage类就在这个库中。

修改这个类的setItem方法,在保存数据的时候加密
[java]  view plain copy
  1. public static void setItem(String key, String value) {  
  2.     try {  
  3.         // 加密数据  
  4.         value = Base64.encodeToString(value.getBytes(), Base64.DEFAULT);  
  5.   
  6.         String sql = "replace into " + TABLE_NAME  
  7.                 + "(key,value)values(?,?)";  
  8.         mDatabase.execSQL(sql, new Object[] { key, value });  
  9.     } catch (Exception e) {  
  10.         e.printStackTrace();  
  11.     }  
  12. }  

修改这个类的getItem方法,在获取数据的时候解密
[java]  view plain copy
  1. public static String getItem(String key) {  
  2.     String ret = null;  
  3.     try {  
  4.         String sql = "select value from " + TABLE_NAME + " where key=?";  
  5.         Cursor c = mDatabase.rawQuery(sql, new String[] { key });  
  6.         while (c.moveToNext()) {  
  7.             // only return the first value  
  8.             if (ret != null) {  
  9.                 Log.e(TAG, "The key contains more than one value.");  
  10.                 break;  
  11.             }  
  12.             ret = c.getString(c.getColumnIndex("value"));  
  13.         }  
  14.         c.close();  
  15.     } catch (Exception e) {  
  16.         e.printStackTrace();  
  17.     }  
  18.       
  19.     // 解密数据  
  20.     if (ret != null) {  
  21.         ret = new String(Base64.decode(ret, Base64.DEFAULT));  
  22.     }  
  23.       
  24.     return ret == null ? "" : ret;  
  25. }  


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值