A. 在c++中怎麼能實現輸入一行字母,將字母加密輸出
簡單的話,可以用凱撒加密演算法,輸入是你的一行明文,和密鑰字元串(這個是保密的),然後將你的明文的每個字元依次和密鑰字元串的每個字元做按位異或操作(如果密鑰過長則截斷,密鑰過短則重復拼接),最終得到密文。解密的方法是把密文再按位異或一遍密鑰。
如果要高級的加密演算法,可以用AES,這個C++加密庫Cryptopp有可直接調用。
B. 非對稱加密中,公鑰在什麼情況下用於加密,什麼情況用於解密
在進行加密的時候,公鑰用於加密,私鑰用於解密
在進行數字簽名的時候,私鑰用於解密,公鑰用於加密
C. C語言寫一個線路加密法或叫換位加密演算法
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
constintMAXSIZE=100;
char*encrypt(char*essay){
inti,j,n,u,v,m,len=strlen(essay);
char*result;
m=n=(int)sqrt(len);
if(m*m<len)++n;
result=(char*)malloc(m*n*sizeof(char)+1);
for(i=0;i<m;++i){
for(j=0;j<n;++j){
u=n*i+j;
v=m*j+i;
if(u<len)result[v]=essay[u];
elseresult[v]='';
}
}
result[m*n]=0;
returnresult;
}
intmain(){
chars[MAXSIZE],*u;
printf("輸入明文: ");
fgets(s,MAXSIZE,stdin);
s[strlen(s)-1]=0;//去除尾部的
u=encrypt(s);
printf("密文是: %s ",u);
free(u);
return0;
}
D. 如何在反編譯的apk中找到加密演算法
所謂APK指的是android操作系統的應用程序安裝文件。所謂Crack,簡單地理解為「破解」。我具體指的是反編譯APK文件進行匯編級的代碼分析,並修改或插入自己的代碼,重新簽名打包為APK文件,以達到改變程序原有行為的目的。
由以上的說明可知,我們要Crack一個APK文件,主要流程有三步:反編譯、代碼分析、重新打包簽名。
基本准備
我們需要一些基本的工具進行一些主要的工作。如果你是一個會做Android APK漢化的朋友,那麼你應該對這些工具非常熟悉:
第一個工具是android-apktool,A tool for reengineering Android apk files 。這個工具是我們完成APK Crack的核心,利用它實現APK文件的反編譯和重新打包。它是Google Code上一個非常著名的開源項目,大家可以在Google Code的網頁上獲取它和它的Wiki、源碼及其他相關信息。
第二個工具是Auto-sign。這個工具實現的是APK打包後的簽名工作,屬於一個小工具。
除了這些基本工具外,為了更好的分析代碼,你可能還需要用到一些其他工具,例如:dex2jar和jd-gui等,這里不做詳述。
反編譯
如果你是一個經常漢化APK程序的朋友,那麼反編譯這一步你肯定不會陌生。不過,既然這篇文章側重於基本流程講解,那麼這一步想來是不能省掉的。所以,覺得羅嗦的朋友,請跳過。首先我們需要有一個待反編譯的APK。這里我自己寫了一個HelloWorld的APK,代碼如下:
package com.zh_weir.helloworld;import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
復制代碼
我們通過android-apktool對這個APK進行反編譯。對於android-apktool的使用,我就不做太多翻譯的工作,直接給出說明文檔吧。簡單一句話,就是命令行執行。
Apktool v1.3.2 - a tool for reengineering Android apk files
Copyright 2010 Ryszard Wi?niewski <[email protected]>
Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
Usage: apktool [-v|--verbose] COMMAND [...]
COMMANDs are:
d[ecode] [OPTS] <file.apk> [<dir>]
Decode <file.apk> to <dir>.
OPTS:
-s, --no-src
Do not decode sources.
-r, --no-res
Do not decode resources.
-d, --debug
Decode in debug mode. Check project page for more info.
-f, --force
Force delete destination directory.
-t <tag>, --frame-tag <tag>
Try to use framework files tagged by <tag>.
--keep-broken-res
Use if there was an error and some resources were dropped, e.g.:
"Invalid config flags detected. Dropping resources", but you
want to decode them anyway, even with errors. You will have to
fix them manually before building.
b[uild] [OPTS] [<app_path>] [<out_file>]
Build an apk from already decoded application located in <app_path>.
It will automatically detect, whether files was changed and perform
needed steps only.
If you omit <app_path> then current directory will be used.
If you omit <out_file> then <app_path>/dist/<name_of_original.apk>
will be used.
OPTS:
-f, --force-all
Skip changes detection and build all files.
-d, --debug
Build in debug mode. Check project page for more info.
if|install-framework <framework.apk>
Install framework file to your system.
For additional info, see: http://code.google.com/p/android-apktool/
復制代碼
通過apktool d HelloWorld.apk的命令,我們就完成了一個簡單的APK的反編譯工作。得到了一個叫做「HelloWorld」的文件夾。你可以看見文件夾下有Manifest文件,有反編譯出的res資源文件。這些東西都是平時漢化特別關心的,而不是我們要注意的重點。我們需要注意的是一個叫做「smali」的文件夾。
仔細觀察,你會發現這個文件夾下的文件組織結構和我們的Android工程中java源碼的組織結構幾乎一致。只不過Java文件被.smali的文件取而代之了。我們用文本編輯器打開這些.smali文件,你會發現它們都是可識別的、並且非常「整齊」的文本文件。
E. MD5碼是不可逆的,但是他的加密演算法是公開的,為什麼不能反向編譯呢
在MD5裡面一些演算法是在理論上可以反向但實際中是很難反向實現的!
F. 現在哪種加密演算法安全AES,IDEA,RC系,Tirple DES,CAST5,Blowfish
AES-256和RSA-2048絕對可以,用RSA加密密匙,AES加密數據,因為非對稱演算法加密數據速度實在太慢,所以用非對稱演算法加密數據根本行不通,但是安全性非常高。