具体 *** 作步骤如下:
1、使用加密工具生成公钥和私钥,并将公钥嵌入到软件中。
2、使用加密工具对软件进行加密,生成加密后的程序。
3、开发注册机程序,生成注册码,并将注册码嵌入到软件中。
4、将加密后的程序和注册机程序打包发布,用户可以通过注册机进行激活,获得软件的使用权限。
这里使用的是按位加密,按ASCII码进行加密的算法自己写个,很容易的。
#include<stdioh>
#include<stdlibh>
#include<conioh>
#include<stringh>
void
dofile(char
in_fname,char
pwd,char
out_fname);/对文件进行加密的具体函数/
void
usage(char
name);
void
main(int
argc,char
argv[])/定义main()函数的命令行参数/
{
char
in_fname[30];/用户输入的要加密的文件名/
char
out_fname[30];
char
pwd[10];/用来保存密码/
if(argc!=4)
{/容错处理/
usage(argv[0]);
printf("\nIn-fname:\n");
gets(in_fname);/得到要加密的文件名/
while(in_fname==NULL)
{
printf("\nIn-fname:\n");
gets(in_fname);
}
printf("Password
6-8:\n");
gets(pwd);/得到密码/
while(pwd==NULL
||
strlen(pwd)>8
||
strlen(pwd)<6)
{
printf("Password
6-8:\n");
gets(pwd);
}
printf("Out-file:\n");
gets(out_fname);/得到加密后你要的文件名/
while(in_fname==NULL)
{
printf("Out-file:\n");
gets(out_fname);
}
while(!strcmp(in_fname,out_fname))
{
printf("文件名不能和源文件相同\n");
printf("Out-file:\n");
gets(out_fname);
}
dofile(in_fname,pwd,out_fname);
printf("加密成功,解密请再次运行程序\n");
}
else
{/如果命令行参数正确,便直接运行程序/
strcpy(in_fname,argv[1]);
strcpy(pwd,argv[2]);
strcpy(out_fname,argv[3]);
while(pwd==NULL
||
strlen(pwd)>8
||
strlen(pwd)<6)
{
printf("Password
faied!\n");
printf("Password
6-8:\n");
gets(pwd);
}
while(!strcmp(in_fname,out_fname))
{
printf("文件名不能和源文件相同\n");
printf("Out-file:\n");
gets(out_fname);
while(in_fname==NULL)
{
printf("Out-file:\n");
gets(out_fname);
}
}
dofile(in_fname,pwd,out_fname);
printf("加密成功,解密请再次运行程序\n");
}
}
/加密子函数开始/
void
dofile(char
in_fname,char
pwd,char
out_file)
{
FILE
fp1,fp2;
register
char
ch;
int
j=0;
int
j0=strlen(pwd);
fp1=fopen(in_fname,"rb");
if(fp1==NULL)
{
printf("cannot
open
in-file\n");
exit(1);/如果不能打开要加密的文件,便退出程序/
}
fp2=fopen(out_file,"wb");
if(fp2==NULL)
{
printf("cannot
open
or
create
out-file\n");
exit(1);/如果不能建立加密后的文件,便退出/
}
/加密算法开始/
while(j0>=0)
{
ch=fgetc(fp1);
while(!feof(fp1))
{
fputc(ch^pwd[j>=j0j=0:j++],fp2);/异或后写入fp2文件/
ch=fgetc(fp1);
}
j0--;
}
fclose(fp1);/关闭源文件/
fclose(fp2);/关闭目标文件/
}
void
usage(char
name)
{
printf("\t=======================File
encryption======================\n");
printf("\tusage:
%s
In-fname
password
out_fname\n",name);
printf("\tExample:
%s
file1txt
12345678
file2txt\n",name);
}
有单表替换加密解密c语言程序希望对你能有所帮助
#include<stdioh>
char a[100];
char d[]={"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
void encryption();
void decryption();
void encryption()
{int i,j;
char b[100];
printf("please input a plaintext:\n");
gets(b);
printf("the ciphertext is:\n");
for(i=0;i<100;i++)
{if(b[i]==' ')
printf("%c",b[i]);
else if(b[i]!='\0')
{for(j=0;j<53;j++)
{if(d[j]==b[i])
printf("%c",a[j]);
}
}
else
break;}
printf("\n");
}
void decryption()
{char c[100];
int i,j,k;
printf("please input the ciphertext:\n");
gets(c);
printf("the plaintext is:\n");
for(i=0;i<100;i++)
{if(c[i]==' ')
printf("%c",c[i]);
else if(c[i]!='\0')
for(j=0;j<27;j++)
{if(a[j]==c[i])
{k=j+97;
printf("%c",k);
}
}
else break;
}
printf("\n");
}
void main()
{int i;
printf("please input 26 letters to form a key:\n");
scanf("%s",a);
list:printf("please choose a function:1encryption 2decryption 3exit\n");
scanf("%d",&i);
getchar();
switch(i){
case 1:encryption();
goto list;break;
case 2:decryption();
goto list;break;
case 3:exit(1);
}
}
using System;
using SystemCollectionsGeneric;
using SystemIO;
using SystemLinq;
using SystemText;
namespace baidu
{
class temp
{
public static void main()
{
//string s = "cn9sky888";
FileStream fs = new FileStream("Passwordtxt", FileMode Open );
StreamReader sr = new StreamReader(fs);
if (FileExists("PasswordMd5txt"))
{
FileDelete("PasswordMd5txt");
}
FileStream fs2 = new FileStream("PasswordMd5txt",FileMode OpenOrCreate );
StreamWriter sw = new StreamWriter(fs2);
string temp = "";
int count = 0;
while(!srEndOfStream )
{
temp = srReadLine();
swWriteLine(temp + "\t" + tempMd5Bit16() + "\t" + tempMd5Bit32());
count++ Show ();
}
}
}
public static class MyExtensions
{
public static string CharToString(this char[] temp)
{
string s = "";
for (int i = 0; i < tempLength; i++)
{
s += temp[i]ToString();
}
return s;
}
#region//string
public static string sort(this string temp)
{
return tempToint()sort()Tochararray()CharToString();
}
public static int[] ToIntArray(this string temp, string spliter)
{
string[] temp2 = tempSplit(spliterToCharArray());
List<int> ls = new List<int>();
for (int i = 0; i < temp2Length; i++)
{
lsAdd(temp2[i]ToInt());
}
return lsToArray();
}
public static int ToInt(this string temp)
{
return intParse(temp);
}
public static int[] Toint(this string temp)
{
List<int> ls = new List<int>();
for (int i = 0; i < tempLength; i++)
{
lsAdd((int)temp[i]);
}
return lsToArray();
}
public static byte ToTinyInt(this string temp)
{
return ConvertToByte(temp);
}
public static int CountNum(this string temp)
{
int sum = 0;
for (int i = 0; i < tempLength; i++)
{
if ((int)temp[i] >= 48 && (int)temp[i] <= 57)
{
sum++;
}
}
return sum;
}
public static int CountLetter(this string temp)
{
int sum = 0;
temp = tempToUpper();
for (int i = 0; i < tempLength; i++)
{
if ((int)temp[i] >= 65 && (int)temp[i] <= 90)
{
sum++;
}
}
return sum;
}
public static int CountOther(this string temp)
{
return tempLength - tempCountLetter() - tempCountNum();
}
public static string Md5Bit32(this string temp)
{
string strResult = "";
string strHashData = "";
byte[] arrbytHashValue;
SystemSecurityCryptographyMD5CryptoServiceProvider oMD5Hasher = new SystemSecurityCryptographyMD5CryptoServiceProvider();
try
{
arrbytHashValue = oMD5HasherComputeHash(SystemTextEncodingDefaultGetBytes(temp));
//oMD5Hasher ComputeHash (
//由以连字符分隔的十六进制对构成的String,其中每一对表示value 中对应的元素;例如“F-2C-4A”
strHashData = SystemBitConverterToString(arrbytHashValue);
//替换-
strHashData = strHashDataReplace("-", "");
strResult = strHashData;
}
catch (SystemException ex)
{
ConsoleWriteLine(exMessage);
}
return strResult;
}
public static string Md5Bit16(this string temp)
{
return tempMd5Bit32()Substring(8, 16);
}
#endregion
#region//int
public static int[] sort(this int[] temp)
{
List<int> ls;
ls = tempToList();
lsSort();
return lsToArray();
}
public static char[] Tochararray(this int[] temp)
{
List<char> ls = new List<char>();
for (int i = 0; i < tempLength; i++)
{
lsAdd((char)temp[i]);
}
return lsToArray();
}
public static int[] Remove(this int[] temp, int tmp)
{
List<int> ls = new List<int>();
ls = tempToList();
lsRemove(tmp);
return lsToArray();
}
public static int[] RemoveAt(this int[] temp, int index)
{
List<int> ls = new List<int>();
ls = tempToList();
lsRemoveAt(index);
return lsToArray();
}
public static int find(this int[] temp, int tmp)
{
return tempToList()IndexOf(tmp);
}
public static int[] insert(this int[] temp, int index, int tmp)
{
temp = tempRemoveAt(index);
List<int> ls = new List<int>();
ls = tempToList();
lsInsert(index, tmp);
return lsToArray();
}
#endregion
#region//init()
public static int[,] init(this int[,] temp)
{
Random rm = new Random();
int rank = tempRank;
int line = tempGetLength(0);
int row = tempLength / line;
for (int j = 0; j < line; j++)
{
for (int i = 0; i < row; i++)
{
temp[j, i] = rmNext(9);
}
}
return temp;
}
public static string init(this string s, int lenght)
{
string temp = "";
Random rm = new Random();
for (int i = 0; i < lenght; i++)
{
temp += ((char)rmNext(65, 90))ToString();
}
return temp;
}
public static int[] init(this int[] temp, int min, int max)
{
Random rm = new Random();
for (int i = 0; i < tempLength; i++)
{
Rand:
int rm2 = rmNext(min, max);
if (!tempToList()Contains(rm2))
temp[i] = rm2;
else
goto Rand;
//temp[i] = rmNext(min,max);
}
return temp;
}
public static bool IsEven(int temp)
{
if (temp % 2 == 0 && temp != 0)
return true;
else
return false;
}
public static bool IsUneven(int temp)
{
if (temp % 2 != 0 && temp != 0)
return true;
else
return false;
}
public static bool Is0(int temp)
{
if (temp == 0)
return true;
else
return false;
}
public static int[] ReturnEven(this int[] temp)
{
return tempToList()FindAll(IsEven)ToArray()sort();
}
public static int[] ReturnUneven(this int[] temp)
{
return tempToList()FindAll(IsUneven)ToArray()sort();
}
public static int[] Return0(this int[] temp)
{
return tempToList()FindAll(Is0)ToArray()sort();
}
#endregion
#region//show
public static void Show(this byte temp)
{
ConsoleWriteLine(temp);
wline();
}
public static void Show(this string temp)
{
ConsoleWriteLine(temp);
wline();
}
public static void Show(this int temp)
{
ConsoleWriteLine(temp);
wline();
}
public static void Show(this int[,] temp)
{
int rank = tempRank;
int line = tempGetLength(0);
int row = tempLength / line;
for (int j = 0; j < line; j++)
{
for (int i = 0; i < row; i++)
{
ConsoleWrite(temp[j, i] + " ");
}
ConsoleWriteLine();
}
wline();
}
public static int[] Show(this int[] temp)
{
for (int i = 0; i < tempLength; i++)
{
ConsoleWrite(temp[i] + " ");
}
ConsoleWriteLine();
wline();
return temp;
}
#endregion
public static void wline()
{
ConsoleWriteLine("-------------------------------------------------------------------");
}
}
}
#include <stdioh>
void main()
{
char str[200];
int i;
gets(str);
for(i=0;str[i]!='\0';i++)
if((str[i]>='a'&&str[i]<='x')||(str[i]>='A'&&str[i]<='X')) str[i]+=2;
else if(str[i]=='y') str[i]='a';
else if(str[i]=='z') str[i]='b';
else if(str[i]=='Y') str[i]='A';
else if(str[i]=='Z') str[i]='B';
puts(str);
}
可参考vivo手机设置软件加密的方法:
1、iQOO (Monster) UI/Funtouch OS 30及以上系统:进入设置--指纹、面部与密码 /指纹与密码/安全--隐私与应用加密,设置隐私密码密保,设置“密码”“密保”完成后点击“应用加密”,打开软件后面对应的开关,即可加密;
2、Funtouch OS 30以下系统:进入i管家--软件管理--软件锁,设置图案密码或使用数字密码,设置完成后,点击右上角的“继续”,设置完成软件密码,即可设置软件锁的密保(即安全问题),然后点击右上角的“完成”,点击软件后面对应的锁状图标,即可加密。
以上就是关于国密2给软件加密注册机怎么 *** 作全部的内容,包括:国密2给软件加密注册机怎么 *** 作、c语言加密解密算法、映射表加密程序(替换密码)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)