英文大写加密
如果要求不高的话,简单点用移位算法就好了,每个字母加N。比如a->c, b->d, ... , z->b.
N就是你的密钥,这里是2
❷ 12.编写一个程序,输入一个字符串,将其中所以的大写英文字母+3,小写字母-3。然后再输出加密后的
#include<stdio.h>
char*Change(chars[]){
inti;
for(i=0;s[i];++i){
if(s[i]>='a'&&s[i]<='z')
s[i]=(26+(s[i]-'a'-3))%26+'a';
if(s[i]>='A'&&s[i]<='Z')
s[i]=(26+(s[i]-'A'+3))%26+'A';
}
returns;
}
char*Change2(chars[]){
inti;
for(i=0;s[i];++i){
if(s[i]>='a'&&s[i]<='z')
s[i]=(26+(s[i]-'a'+3))%26+'a';
if(s[i]>='A'&&s[i]<='Z')
s[i]=(26+(s[i]-'A'-3))%26+'A';
}
returns;
}
intmain(){
chara[]="dsereaiklfiwieik",b[]="slASSFGGHHJHKKIUUYUYYHHNJKK";
printf("转换前:%s ",a);
printf("转换后:%s ",Change(a));
printf("恢复后:%s ",Change2(a));
printf("转换前:%s ",b);
printf("转换后:%s ",Change(b));
printf("恢复后:%s ",Change2(b));
return0;
}
 #include<stdio.h>
#include<stdio.h>
#include<ctype.h>
intmain()
{inti;
chars[200];
gets(s);
for(i=0;s[i];i++)
if(isalpha(s[i]))
{s[i]+=3;
if(s[i]%0x20>26)s[i]-=26;
}
puts(s);
return0;
}
❹ 纯数字的加密成4位英文字母的方式(一般用于网站)
做回好人,回答你吧。直接看代码:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class jiami {
 public static void main(String[] args) { 
  String source=null,target=null;
  try {  
            FileInputStream fileread = new FileInputStream(new File("D:/a.txt"));//路径自己改  
            int length = fileread.available();  
            byte[] buffer = new byte[length];  
            fileread.read(buffer);  
            source = new String(buffer);//读取
            fileread.close();
        } catch (Exception e) {  
            e.printStackTrace();  
        }
  if(source==null)
  System.out.println("a.txt为空");
  else{
   System.out.println(source);
   target=zhuanhuan(source);
   System.out.println(target);
   try {
    FileOutputStream out = new FileOutputStream(new File("D:/b.txt"));
    out.write(target.getBytes());//写入
    out.close();
   } catch (FileNotFoundException e1) {
    e1.printStackTrace();
   } catch (IOException e) {
    e.printStackTrace();
   }
  }
 }
 public static String zhuanhuan(String s){
  char []array = s.toCharArray();
  for(int i=0;i<array.length;i++){
  //字母转换这里用ASCII码来,方便快捷,大写字母是65-90,小写字母是97-122
   int j = (int)array[i];
   if(j>=65&&j<=90){
    if(j==90)
     j=65;
    else j=j+1; 
    array[i]=(char)j;
   }
   if(j>=97&&j<=122){
    if(j==122)
     j=97;
    else j=j+1; 
    array[i]=(char)j;
   }
  //数字转换的话由于数字比较少,就直接转换了,不用ASCII码了
   if(array[i]=='1')
    array[i]='0';
   else if(array[i]=='2')
    array[i]='9';
   else if(array[i]=='3')
    array[i]='8';
   else if(array[i]=='4')
    array[i]='7';
   else if(array[i]=='5')
    array[i]='6';
   else if(array[i]=='6')
    array[i]='5';
   else if(array[i]=='7')
    array[i]='4';
   else if(array[i]=='8')
    array[i]='3';
   else if(array[i]=='9')
    array[i]='2';
   else if(array[i]=='0')
    array[i]='1';  
  }
  return new String(array); 
 }
}
纯手打。不采纳对不起观众啊!!!
❺ 输入一个字符串,将其进行加密,加密的方式是每个大写英文字母用它后面的字母代替,即’A’变成’B’
#include<stdio.h>
int main() {
char s[100];
int i=0;
gets(s);
for(; s[i]!='\0'; i++) {
if(s[i]>='A' && s[i]<='Z')
printf("%c",s[i]=='Z'?'A':s[i]+1);
else printf("%c",s[i]);
}
}
❻ c语言对大写英文字母加密
#include <stdio.h>
#include <string.h>
int main()
{
   char passwd[100],encrypted[100];
   int i,j,k,t,move;  
  while(1)
    {
        printf("Enter message to be encrypted:");
        
gets(passwd);
       
  move=3;    
 for(i=0; i<strlen(passwd); i++)
        {          
 if(passwd[i] >= 'A' && passwd[i] <= 'Z')
            {
          
      passwd[i] = ((passwd[i]-'A')+move)%26+'A';
          
  }  else if(passwd[i] >= 'a' && passwd[i] <= 'z')
       {
          
     passwd[i] = ((passwd[i]-'a')+move)%26+'a';
          
  }
    
   }
    
   printf("%s",passwd);
    
   printf("\n");
    
}  
 return 0;
}
这道题实际上就是C语言版的凯撒加密(字母往后面移动1-25之间的任意一位数)
❼ 将26个英文大写字母依次用整数0,1,2...25代表。某加密程序如下:设某个字母用
请详细补充题目!
  中途逻辑性需要加强!
❽ 文件的加密. 使用“二战”时简单的加密算法,即将英文的大写字母或小写字母循
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#defineMAX_FILE_NAME128
#defineMAX_STRING_SIZE256
voidencrypt(void);
voiddecode(void);
voipper(void);
voidlower(void);
voidfix(void);
intmain(intargc,char**argv)
{
intcommand=1;
while(command!=0)
{
printf("%-16s%-16s%-16s%-16s%-16s%-16s ","1.encrypt","2.decode","3.toupper","4.tolower","5.autofix","0.exit");
printf("entercommond'snumber:");
scanf("%d",&command);
switch(command)
{
case1:encrypt();break;
case2:decode();break;
case3:upper();break;
case4:lower();break;
case5:fix();break;
case0:break;
}
}
return0;
}
voidencrypt(void)
{
charsource[MAX_FILE_NAME];
chardestination[MAX_FILE_NAME];
printf("enterthefile'spathyouwanttoencrypt:");
scanf("%s",source);
printf(":");
scanf("%s",destination);
FILE*input=fopen(source,"r");
if(input==NULL)
{
printf("openfilefail ");
system("pause");
exit(1);
}
FILE*output=fopen(destination,"w");
if(output==NULL)
{
printf("createfilefail ");
system("pause");
exit(1);
}
intinch=fgetc(input);
while(!feof(input))
{
if(inch>='a')
fputc((char)('a'+(inch+4)%'a'),output);
else
fputc((char)('A'+(inch+4)%'A'),output);
inch=fgetc(input);
}
fclose(input);
fclose(output);
printf("complete ");
}
voiddecode(void)
{
charsource[MAX_FILE_NAME];
chardestination[MAX_FILE_NAME];
printf("enterthefile'spathyouwanttoencrypt:");
scanf("%s",source);
printf(":");
scanf("%s",destination);
FILE*input=fopen(source,"r");
if(input==NULL)
{
printf("openfilefail ");
system("pause");
exit(1);
}
FILE*output=fopen(destination,"w");
if(output==NULL)
{
printf("createfilefail ");
system("pause");
exit(1);
}
intinch=fgetc(input);
while(!feof(input))
{
if(inch>='a')
fputc((char)('a'+(inch+22)%'a'),output);
else
fputc((char)('A'+(inch+22)%'A'),output);
inch=fgetc(input);
}
fclose(input);
fclose(output);
printf("complete ");
}
voipper(void)
{
charinput[MAX_STRING_SIZE];
printf("inputasentence:");
scanf("%s",input);
charmode;
fflush(stdin);
printf("?(y/n):");
scanf("%c",&mode);
if(mode=='y')
printf("%s ",strupr(input));
else
{
char*temp=strlwr(input);
intlength=strlen(temp);
intj=length-1;
while(j>=0)
{
if(temp[j]=='.')
if(j+1<length)
if(temp[j+1]>='a')
temp[j+1]-=32;
j--;
}
printf("%s ",temp);
}
}
voidlower(void)
{
charinput[MAX_STRING_SIZE];
printf("inputasentence:");
scanf("%s",input);
char*temp=strlwr(input);
intlength=strlen(temp);
intj=length-1;
while(j>=0)
{
if(temp[j]=='.')
if(j+1<length)
if(temp[j+1]>='a')
temp[j+1]-=32;
j--;
}
if(length!=0)
if(temp[0]>='a')
temp[0]-=32;
printf("%s ",temp);
}
voidfix(void)
{
charinput[MAX_STRING_SIZE];
charoutput[MAX_STRING_SIZE];
printf("inputasentence:");
fflush(stdin);
gets(input);
intlength=strlen(input);
if(input[length-1]!='.')
input[length]='.',length++;
intcurrent=0,patt=0;
if(length)
output[current++]=toupper(input[patt++]);
while(patt<length)
{
if(input[patt]==','||input[patt]=='.')
{
intmode=0;
if(input[patt]=='.')
mode=1;
output[current++]=input[patt++];
output[current++]='';
while(patt<length&&(input[patt]==''||input[patt]==' '))
patt++;
if(patt<length&&mode)
output[current++]=toupper(input[patt++]);
}
elseif(input[patt]==''||input[patt]==' ')
{
output[current++]='';
while(patt<length&&(input[patt]==''||input[patt]==' '))
patt++;
}
else
output[current++]=input[patt++];
}
printf("%s ",output);
}

❾ 从键盘上输入一个字符串存放在一个字符数组中,按以下规则加密:所有的大写英文字母加3,小写英文字母减
int main()
{
  char str1[50],str2[50];
  printf("请输入字符串:|n");
  gets(str1);
  for(int i=0;str1[1]='\0';i++)
  {
  if(str1[i]>='a'&&str1[i]<='z')
       str1[i]=str1[i]-4;
  if(str1[i]>='A'&&str1[i]<='Z')
       str1[i]=str1[i]+3;
   str2[i]=str1[i];
  }
 printf("原字符串为:");
 puts(str1);
 printf("加密后字符串为:");
  puts(str2);
  return 0;
}
