導航:首頁 > 文檔加密 > 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設計字元串加密解密相關的資料

熱點內容
如何在文件夾中顯示頁碼 瀏覽:354
雲伺服器登不上qq 瀏覽:417
程序員四級工程師 瀏覽:715
薄荷app怎麼把體重清零 瀏覽:644
草料二維碼加密怎麼製作 瀏覽:851
04s519隔油池圖集pdf 瀏覽:242
程序員搞測試 瀏覽:552
蘋果app應用隱藏了怎麼辦 瀏覽:660
PDF調取 瀏覽:199
獨立柱加密需要什麼條件 瀏覽:814
php培訓出來找不到工作 瀏覽:106
小程序克隆源碼 瀏覽:448
python整數整除負數 瀏覽:880
遮天用什麼小說app看 瀏覽:645
什麼可以發類似朋友圈的app 瀏覽:495
cmd查找命令行 瀏覽:661
如何申請域名需要虛擬伺服器 瀏覽:497
氣體流量的演算法 瀏覽:634
大族加密狗滑鼠 瀏覽:23
php資料庫登錄界面 瀏覽:657