base64加密解密c++代码
关于base64加密解密代码:
程序运行功能请自行查看main函数:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
char str[70];
char str1[1000];
char ch[1000010];
int ch1[1000010];
void f()
{
int i,j;
memset(str,0,sizeof(str));
memset(str1,0,sizeof(str1));
j=0;
for(i=0;i<26;i++){
str1[i+'A']=j;
str[j++]=i+'A';
}
for(i=0;i<26;i++){
str1[i+'a']=j;
str[j++]=i+'a';
}
for(i=0;i<=9;i++){
str1[i+'0']=j;
str[j++]=i+'0';
}
str1['+']=j;
str[j++]='+';
str1['/']=j;
str[j++]='/';
str[j++]='\0';
str1['=']=0;
/*for(i=0;i<65;i++){
printf("%c ",str[i]);
}
printf("\n");*/
}
void jiami ()
{
int len=strlen(ch);
int i,j,k=0;
int m,l;
for(i=len-1;i>=0;i--){
for(j=0;j<8;j++){
ch1[k++]=ch[i]%2;
ch[i]/=2;
}
}
m=0;
for(i=k-1,j=0,l=0;;i--,j++){
if(j>=6){
if(i>-6)
printf("%c",str[m]);
else printf("=");
l++;j=0;m=0;
if(l%76==0){
printf("\n");
}
if(i<=0&&l%4==0){
break;
}
}
if(i>=0)
m=m*2+ch1[i];
else m*=2;
}
printf("\n");
}
void jiemi ()
{
int len=strlen(ch);
int i,j,k=0,l;
int x;
for(i=len-1;i>=0;i--){
x=str1[ch[i]];
//printf("%c %d\n",ch[i],x);
//system("pause");
for(j=0;j<6;j++){
ch1[k++]=x%2;
x/=2;
// printf("%d ",ch1[k-1]);
}
}
// printf("\n");
int m=0;
for(i=k-1,j=0,l=0;;i--,j++){
if(j>=8){
if(i>-8){
printf("%c",m);l++;
if(l%76==0){
printf("\n");
}
}
j=0,m=0;
if(i<=0)
break;
}
if(i>=0)
m=m*2+ch1[i];
else m*=2;
}
printf("\n");
}
int main ()
{
f();
//printf("%d\n",str1['2']);
int i,j,l=0;
while(~scanf("%s",ch)){
l++;
if(strcmp(ch,"#exit#")==0)
break;
printf("Case #%d\n",l);
if(strcmp(ch,"#s2b#")==0){
getchar();
while(gets(ch)!=NULL){
if(strcmp(ch,"#CaseEnd#")==0)
break;
jiami();
}
}else if(strcmp(ch,"#b2s#")==0){
getchar();
while(gets(ch)!=NULL){
if(strcmp(ch,"#CaseEnd#")==0)
break;
jiemi();
}
}
}
return 0;
}
base64加密解密c++代码的更多相关文章
- 【代码笔记】iOS-3DES+Base64加密解密
一,工程目录. 二,代码. RootViewController.m #import "RootViewController.h" #import "NSString+T ...
- Base64加密解密原理以及代码实现(VC++)
Base64加密解密原理以及代码实现 转自:http://blog.csdn.net/jacky_dai/article/details/4698461 1. Base64使用A--Z,a--z,0- ...
- php使用base64加密解密图片
php使用base64加密解密图片的实例代码. 例子: <?php //文件名:base64.php $data="/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAB ...
- password学3——Java BASE64加密解密
Base64是网络上最常见的用于传输8Bit字节代码的编码方式之中的一个,大家能够查看RFC2045-RFC2049.上面有MIME的具体规范.Base64编码可用于在HTTP环境下传递较长的标识信息 ...
- 使用jframe编写一个base64加密解密工具
该工具可以使用exe4j来打包成exe工具(如何打包自己百度) 先上截图功能 运行main方法后,会弹出如下窗口 输入密文 然后点击解密,在点格式化 代码分享 package tools;import ...
- Base64加密解密工具类
使用Apache commons codec类Base64进行加密解密 maven依赖 <dependency> <groupId>commons-codec</grou ...
- Java android DES+Base64加密解密
服务器与客户端加密解密传输, 中间遇到各种坑,客户端无论用AES还是DES解密时都会出现错误,后来才看到好多人说要用AES/DES加完密后还要BASE64加密,照做时发现android和java的Ba ...
- Java语言实现 Base64 加密 & 解密
Java语言实现 Base64 加密 & 解密 Base64是网络上最常见的用于传输8Bit字节码的编码方式之一,Base64就是一种基于64个可打印字符来表示二进制数据的方法. Base64 ...
- JS实现base64加密解密
JS实现base64加密解密 转载自http://blog.csdn.net/fengzheng0306/archive/2006/04/25/676055.aspx 方法一: <HTML> ...
随机推荐
- google搜索小技巧
google搜索小技巧 一.总结 一句话总结:But most people may not be using Google search to its full potential.Want to ...
- SpringBoot集成TkMybatis插件
前提: 基于SpringBoot项目,正常集成Mybatis后,为了简化sql语句的编写,甚至达到无mapper.xml文件. 在本篇总结教程,不在进行SpringBoot集成Mybatis的概述. ...
- spring cloud: Hystrix(三):健康指数 health Indicator
spring cloud: Hystrix(三):健康指数 health Indicator ribbon+hystrix 当使用Hystrix时(spring-cloud-starter-hystr ...
- every day a practice —— morning(5)
Huawei has not been accused of wrongdoing. As an administrative subpoena, the Treasury document does ...
- Node.js 知识(教程)
JavaScript on the Server JavaScript was originally built for web browsers, but with Node.js we can u ...
- You Don't Know JS: Scope & Closures (第4章: Hoisting)
Chapter4: Hoisting 变量附加到哪个层次的scope,由它们在哪里和如何声明(let, var)来决定. Function scope/Block scope都有相同的法则:任何变量在 ...
- 创建gitlab ssh 密钥
SSH代表用于管理网络,操作系统和配置的Secure Shell或Secure Socket Shell,并且每次都不需要使用用户名和密码即可验证GitLab服务器. 您可以设置SSH密钥以提供计算机 ...
- spring boot(十七)上传文件
上传文件是互联网中常常应用的场景之一,最典型的情况就是上传头像等,今天就带着带着大家做一个Spring Boot上传文件的小案例. 1.pom包配置 我们使用Spring Boot最新版本1.5.9. ...
- 【PowerDesigner】【9】禁止Name与Code同步
问题:修改了某个字段的name,其code也跟着修改 步骤:Tools→General Options..→Dialog→取消勾选“Name to Code mirroring”复选框 参考博客: 1 ...
- hive的jdbc使用
①新建maven项目,加载依赖包 在pom.xml中添加 <dependency> <groupId>jdk.tools</groupId> <artifa ...