純數字加密
① 對純數字加密有什麼好的辦法
多了,des、aes、base64、rsa、md5、sha等等,等等,數不勝數。每一種演算法,都可以將數字字母加密成純數字。因為加密的結果可以再加密。比如aes加密後的密文,是16進制的東西,我們可以把這個結果轉換成10進制,不就成了純數字了嗎?所以,所有演算法,都可以實現你所說的。
② php純數字加密為可逆的定長密文
你這不是md5加密嗎,sql直接寫就行了。
你在資料庫工具中執行一下,select md5(1);
或者php的md5函數
echo md5(1);
php自帶可逆的加密是base64_encode和base64_decode,但是這個不是等長的,根據輸入的內容變換長度。估計這個不適合你。
你還是網路」php加密解密「吧,有現成的函數。
③ 誰能提供一個java的純數字加密的方法,要從8位變為16位,生成的加密數據要看起來沒有規律
public class DesUtil {
/** 字元串默認鍵值 */
private static String strDefaultKey = "national";
/** 加密工具 */
private Cipher encryptCipher = null;
/** 解密工具 */
private Cipher decryptCipher = null;
/**
* 將byte數組轉換為表示16進制值的字元串, 如:byte[]{8,18}轉換為:0813, 和public static byte[]
* hexStr2ByteArr(String strIn) 互為可逆的轉換過程
*
* @param arrB
* 需要轉換的byte數組
* @return 轉換後的字元串
* @throws Exception
* 本方法不處理任何異常,所有異常全部拋出
*/
public static String byteArr2HexStr(byte[] arrB) throws Exception {
int iLen = arrB.length;
// 每個byte用兩個字元才能表示,所以字元串的長度是數組長度的兩倍
StringBuffer sb = new StringBuffer(iLen * 2);
for (int i = 0; i < iLen; i++) {
int intTmp = arrB[i];
// 把負數轉換為正數
while (intTmp < 0) {
intTmp = intTmp + 256;
}
// 小於0F的數需要在前面補0
if (intTmp < 16) {
sb.append("0");
}
sb.append(Integer.toString(intTmp, 16));
}
return sb.toString();
}
/**
* 將表示16進制值的字元串轉換為byte數組, 和public static String byteArr2HexStr(byte[] arrB)
* 互為可逆的轉換過程
*
* @param strIn
* 需要轉換的字元串
* @return 轉換後的byte數組
* @throws Exception
* 本方法不處理任何異常,所有異常全部拋出
* @author <a href="mailto:[email protected]">LiGuoQing</a>
*/
public static byte[] hexStr2ByteArr(String strIn) throws Exception {
byte[] arrB = strIn.getBytes();
int iLen = arrB.length;
// 兩個字元表示一個位元組,所以位元組數組長度是字元串長度除以2
byte[] arrOut = new byte[iLen / 2];
for (int i = 0; i < iLen; i = i + 2) {
String strTmp = new String(arrB, i, 2);
arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16);
}
return arrOut;
}
/**
* 默認構造方法,使用默認密鑰
*
* @throws Exception
*/
public DesUtil() throws Exception {
this(strDefaultKey);
}
/**
* 指定密鑰構造方法
*
* @param strKey
* 指定的密鑰
* @throws Exception
*/
public DesUtil(String strKey) throws Exception {
Security.addProvider(new com.sun.crypto.provider.SunJCE());
Key key = getKey(strKey.getBytes());
encryptCipher = Cipher.getInstance("DES");
encryptCipher.init(Cipher.ENCRYPT_MODE, key);
decryptCipher = Cipher.getInstance("DES");
decryptCipher.init(Cipher.DECRYPT_MODE, key);
}
/**
* 加密位元組數組
*
* @param arrB
* 需加密的位元組數組
* @return 加密後的位元組數組
* @throws Exception
*/
public byte[] encrypt(byte[] arrB) throws Exception {
return encryptCipher.doFinal(arrB);
}
/**
* 加密字元串
*
* @param strIn
* 需加密的字元串
* @return 加密後的字元串
* @throws Exception
*/
public String encrypt(String strIn) throws Exception {
return byteArr2HexStr(encrypt(strIn.getBytes()));
}
/**
* 解密位元組數組
*
* @param arrB
* 需解密的位元組數組
* @return 解密後的位元組數組
* @throws Exception
*/
public byte[] decrypt(byte[] arrB) throws Exception {
return decryptCipher.doFinal(arrB);
}
/**
* 解密字元串
*
* @param strIn
* 需解密的字元串
* @return 解密後的字元串
* @throws Exception
*/
public String decrypt(String strIn) throws Exception {
return new String(decrypt(hexStr2ByteArr(strIn)));
}
/**
* 從指定字元串生成密鑰,密鑰所需的位元組數組長度為8位 不足8位時後面補0,超出8位只取前8位
*
* @param arrBTmp
* 構成該字元串的位元組數組
* @return 生成的密鑰
* @throws java.lang.Exception
*/
private Key getKey(byte[] arrBTmp) throws Exception {
// 創建一個空的8位位元組數組(默認值為0)
byte[] arrB = new byte[8];
// 將原始位元組數組轉換為8位
for (int i = 0; i < arrBTmp.length && i < arrB.length; i++) {
arrB[i] = arrBTmp[i];
}
// 生成密鑰
Key key = new javax.crypto.spec.SecretKeySpec(arrB, "DES");
return key;
}
/**
* main方法 。
*
* @author 劉堯興
* @param args
*/
public static void main(String[] args) {
try {
String test = "asc";
DesUtil des = new DesUtil("abc");// 自定義密鑰
// System.out.println("加密前的字元:" + test);
// System.out.println("加密後的字元:" + des.encrypt(test));
// System.out.println("解密後的字元:" + des.decrypt(des.encrypt(test)));
} catch (Exception e) {
e.printStackTrace();
}
}
}
④ Delphi常用的字元串(密碼)加密方式都有哪幾種哪種方法可以將數字字母混合加密成純數字
多了,des、aes、base64、rsa、md5、sha等等,等等,數不勝數。每一種演算法,都可以將數字字母加密成純數字。因為加密的結果可以再加密。比如aes加密後的密文,是16進制的東西,我們可以把這個結果轉換成10進制,不就成了純數字了嗎?所以,所有演算法,都可以實現你所說的。
⑤ 純數字的加密成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);
}
}
純手打。不採納對不起觀眾啊!!!
⑥ 如何改動md5加密演算法生成純數字密碼
生成結果字元串逐位元組 (C - 48) MOD 10 不就完了。
得到的是整型變數,需要字元型變數的話再+48
⑦ 請教一個問題,使用什麼加密方式可以把一個字元串變成一串純數字
字元串中字元的種類,按照ASCII碼編碼來說有256種,而普通數字每位只有10種,那麼編碼後的數字字元串必然要比編碼前長,比如說是之前的3倍長。
最簡單的方法是直接將每個字元的ASCII碼用ASCII碼取值寫出來,比如大寫字母A的ASCII碼是65,那麼就寫成065,3個一組表示一個字元;再想加密可以在這個3位數上進行運算,採用比如全都加一個數之類的方法。
⑧ 簡單的數字加密
簡單加密,很簡單啊,
比如說,+6, 乘以3
得到的肯定是兩位數是把,
然後,在前面任意加兩位數,組成一個四位數,全部數據以四位數排列,
你自己要寫清楚,
這樣的話,直接破解,就麻煩多了,如果不知道,前面兩位是多餘的,呵呵
還可以採取,一定的規律, 比如 1 3 4 ,自己寫一組數據記錄下來,
然後, 前面加數據的時候,奇數,任意加,在前面,偶爾加在後面,
難道又增加了 呵呵~~
⑨ 純數字的16位的密碼,是什麼加密
僅憑密碼位數是沒有辦法判斷使用的加密方法的
就拿超級加密3000來說吧,設置文件夾或者文件加密的密碼是1——32位,純數字可以,純字母可以,或者是字母和數字的結合都是可以的。
你這個密碼位數並不能作為判斷加密方法的依據的