导航:首页 > 文档加密 > qt设计字符串加密解密

qt设计字符串加密解密

发布时间:2022-04-02 07:18:13

㈠ c++实现字符串加密,按照下面的加密过程写代码。。

#include <iostream>
using namespace std;
int main()
{
char a[16]{};
cout << "输入15个字符:" << endl;
cin >> a;
for (int i = 2; i<4; i++)
{
a[i] ^= a[8 - i] ^= a[i] ^= a[8 - i];
a[i] = a[i]+1 ;
a[8 - i] = a[8 - i] +1;
}
cout << a << endl;
return 0;
}
3到7逆序之后加1,中间的5不加
输出128755489123456

㈡ 6.设计一个加密解密程序。输入一串字符,使用加密算法,对其加密。再设计解密算法,对其解密。

#include<stdio.h>
intmain()
{chars[200];
inti;
gets(s);
for(i=0;s[i];i++)
s[i]+=i%5+1;
printf("加密后: %s ",s);
for(i=0;s[i];i++)
s[i]-=i%5+1;
printf("解密后: %s ",s);
return0;
}

PrivateSubCommand1_Click()
s=InputBox("请输入要加密的字符串:")
Print"输入的字符串是:"
Prints
Fori=1ToLen(s)
Mid(s,i,1)=Chr(Asc(Mid(s,i,1))+iMod5+1)
Nexti
Print
Print"加密后的串:"
Prints
Fori=1ToLen(s)
Mid(s,i,1)=Chr(Asc(Mid(s,i,1))-iMod5-1)
Nexti
Print
Print"解密后的串:"
Prints
EndSub

㈢ #试一试#  编写程序实现简单的字符串加密

代码和运行情况如下:

㈣ qt aes怎么输入密文解密

包含4个步骤:
1.AddRoundKey — 矩阵中的每一个字节都与该次轮密钥(round key)做XOR运算;每个子密钥由密钥生成方案产生。
2.SubBytes — 通过一个非线性的替换函数,用查找表的方式把每个字节替换成对应的字节。
3.ShiftRows — 将矩阵中的每个横列进行循环式移位。
4.MixColumns — 为了充分混合矩阵中各个直行的操作。这个步骤使用线性转换来混合每内联的四个字节。
最后一个加密循环中省略MixColumns步骤,而以另一个AddRoundKey取代。

㈤ 字符串的加密,解密;加密规则为:字符串中的每个字符加4,之后字符串进行倒置; 如用户输入为“abcd“,

System.Console.WriteLine("请选择输入要加密的字符串(输入1)还是输入要解密的字符串(输入2):");
int temp = int.Parse(System.Console.ReadLine());
if (temp == 1)
{
System.Console.WriteLine("请输入要加密的字符串:");
String str = System.Console.ReadLine(), strc = "";
char[] chs = new char[str.Length];
int j = 0;
foreach (char ch in str)
{
chs[j++] = ch;
}
for (j = 0; j < chs.Length; j++)
{
chs[j] = Convert.ToChar(Convert.ToInt32(chs[j]) + 4);
}
for (j = chs.Length - 1; j >= 0; j--)
{
strc = strc + chs[j];
}
System.Console.WriteLine("加密后的字符串:");
System.Console.WriteLine(strc);
}
else if (temp == 2)
{
System.Console.WriteLine("请输入要解密的字符串:");
String str = System.Console.ReadLine(), strc = "";
char[] chs = new char[str.Length];
int j = 0;
foreach (char ch in str)
{
chs[j++] = ch;
}
for (j = 0; j < chs.Length; j++)
{
chs[j] = Convert.ToChar(Convert.ToInt32(chs[j]) - 4);
}
for (j = chs.Length - 1; j >= 0; j--)
{
strc = strc + chs[j];
}
System.Console.WriteLine("解密后的字符串:");
System.Console.WriteLine(strc);
}
else
{
System.Console.WriteLine("输入有误,退出");
return;
}
System.Console.WriteLine();

㈥ 如何将一个字符串加密成固定或者定长字符串,并解密

将任意长度字符串加密成定长字符串是可能的,但逆向解密是不可能的。
可以加密为可变长度的字符串再解密,或者也可以将一定长度范围内的字符串加密为定长字符串并解密。

㈦ 对输入的字符串进行简单加密处理,并输出加密后的字符串

#include<stdio.h>
#include<string.h>
voidencodedecode(char*s,charc,intn){inti;for(i=0;i<n;i++,s++)*s^=c;}
voidmain(){chars[256],s1[20],c;intn,i;
printf("请输入字符串:");gets(s);n=strlen(s);
printf("请输入加密密钥(单个字符):");gets(s1);c=s1[0];
encodedecode(s,c,n);
printf("加密后的字符串:");for(i=0;i<n;i++)printf("%c",s[i]);printf(" ");
encodedecode(s,c,n);
printf("解密后的字符串:");for(i=0;i<n;i++)printf("%c",s[i]);printf(" ");
}

㈧ 编写程序,实现对任意字符串的加密和解密操作

Dim a() As String, b() As Integer, n As Integer
Text2 = ""
n = Len(Text1)
ReDim a(n)
ReDim b(n + 3)
For i = 1 To n
a(i) = Mid(Text1, i, 1)
If (Asc(a(i)) >= 65 And Asc(a(i)) <= 90) Or (Asc(a(i)) >= 97 And Asc(a(i)) <= 122) Then
b(i) = Asc(a(i)) + 3
If b(i) > Asc("Z") And b(i) < Asc("a") Then b(i) = Asc("A") + b(i) - Asc("Z") - 1
If b(i) > Asc("z") Then b(i) = Asc("a") + b(i) - Asc("z") - 1
Else
b(i) = Asc(a(i))
End If

a(i) = Chr(b(i))
Text2 = Text2 & a(i)
Next
Text3 = Text2
End Sub
Private Sub Command2_Click()
Dim a() As String, b() As Integer, n As Integer
Text4 = ""
n = Len(Text3)
ReDim a(n)
ReDim b(n + 3)
For i = 1 To n
a(i) = Mid(Text3, i, 1)
If (Asc(a(i)) >= 65 And Asc(a(i)) <= 90) Or (Asc(a(i)) >= 97 And Asc(a(i)) <= 122) Then
b(i) = Asc(a(i)) - 3
If b(i) >= 62 And b(i) < Asc("A") Then b(i) = Asc("Z") - (Asc("A") + b(i)) + 1
If b(i) >= 94 And b(i) < Asc("a") Then b(i) = Asc("z") - Asc("a") + b(i) + 1
Else
b(i) = Asc(a(i))
End If
a(i) = Chr(b(i))
Text4 = Text4 & a(i)
Next
End Sub
为便于调试对照,其中将加密后的文件直接放在了TEXT3中。调试完可去掉

㈨ qt如何对字符串进行md5加密,保存到文件,然后能读取到解密到文件

#include<QCryptographicHash>
#include<QSettings>
#include<QDebug>

//generateMD5-Hash
QStringtest_string("ateststringforMD5hash");
QByteArraymd5_hash;
md5_hash=QCryptographicHash::hash(test_string.toUtf8(),QCryptographicHash::Md5);
QStringmd5hash_string=md5_hash.toHex();

qDebug()<<"MD5-Hash:"<<md5hash_string;

//writetomd5_hash.ini
QSettingsmd5writeFile(QString("md5_hash.ini"),QSettings::IniFormat);
md5writeFile.setValue(QLatin1String("MD5-Hash"),md5_hash);
md5writeFile.sync();

//readfrommd5_hash.ini
QSettingsmd5readFile(QString("md5_hash.ini"),QSettings::IniFormat);
md5readFile.sync();

if(true==md5readFile.contains("MD5-Hash")){
QByteArraymd5_array=md5readFile.value("MD5-Hash").toByteArray();

qDebug()<<"MD5-Hashreadfromfile:"<<md5_array.toHex();
}

以上代码纯手敲并且Qt上验证通过的,请珍惜使用。

㈩ QT如何进过MD5加密的密码比对呢

同一个密码经过MD5加密不可能不一样。

阅读全文

与qt设计字符串加密解密相关的资料

热点内容
程序员怎么跟男朋友说我爱你 浏览:309
单片机频率变化 浏览:428
哪个app可以看赌神 浏览:466
rstudiopython 浏览:127
团队如何开发服务器 浏览:440
php选择数据库的函数 浏览:772
dhcp服务器新增地址 浏览:930
程序员跑三个月外卖 浏览:941
linux配置tomcat的jdk路径 浏览:363
液体压缩公式 浏览:777
php开发后台管理系统 浏览:360
python二分查找递归 浏览:447
微信如何发视频不压缩 浏览:902
河北2021美术高考综合分算法 浏览:606
如何为电脑文件夹加密 浏览:835
电脑自启动应用命令 浏览:690
php判断一个文件是否存在 浏览:829
php导出xml文件 浏览:904
7个文件夹解压 浏览:383
python实现机器码 浏览:356