phprc4加密
沒貼出來具體代碼,無法直接定位,挨個排查吧
1、演算法部分的代碼有缺陷
2、文件編碼沒有統一
3、HTML編碼,比如瀏覽器設置成自動識別並且html沒有指定輸出編碼方式
Ⅱ PHP有什麼文本加密函數!
可以使用DES ,我個人是使用DES, 因為有時候需要用到PHP+c# 所以DES是最好的選擇
Ⅲ php openssl生成的rsa密鑰給android和ios使用注意哪些問題
openssl的功能:*生成RSA,DSA雙密匙(還可以再給他們簽名)*生成X509證書*計算印章(MD5,SHA,,RIPEMD160)用於加密大文件*加密,解密(演算法有DES,IDEA,RC2,RC4,Blowfish)*SSL伺服器端/客戶端測試*處理簽名或加密了的
Ⅳ 求C#和PHP的RC4相互加密解密
使用這個類應該可以實現的,只不不過你提出文件是早期的DES,只能是64bits加必,而現在卻是不同的,它與net2.0版本中是一致的,而是高版本中必須設置這幾個相應的屬性。 請查看 DESCryptoServiceProvider類的欄位或屬性,然後再進行測試。
Ⅳ 易語言與PHP RC4加密解密的問題
位密碼演算法:DES 三重DES(Triple-DES)仍然是很安全的,但是也只是在別無他法的情況下的一個較好的選擇。顯然高級加密標准(AES)是一個更好的加密演算法,NIST用AES代替Triple-DES作為他們的標准(下面有更詳細的討論)。其他較好的演算法包括另外兩個AES的變種演算法Twofish和Serpent-也稱為CAST-128,它是效率和安全的完美結合。這幾個演算法不僅比DES更安全,而且也比DES的速度更快。為什麼要使用一些又慢又不安全的演算法呢?SHA1是一個哈希函數,而不是一個加密函數。作為一個哈希函數,SHA1還是相當優秀的,但是還需要幾年的發展才能用作加密演算法。如果你正在設計一個新系統,那麼謹記你可能會在若干年後用SHA1代替目前的演算法。我再重復一遍:只是可能。呵呵,希望能幫到你!謝謝望採納哦!
Ⅵ php加密文件 解密data 轉nsstring 為nil. rc4 ios
IOS:引入ios自帶庫 #include
先以DES加密演算法為例講解,DES的加密和解密都同用一個Key,下面兩個加解密函數如下:
//加密
-(NSString *) encryptUseDES:(NSString *)clearText key:(NSString *)key
{
//一般對加密的字元串採用UTF-8編碼 NSData存儲的就是二進制數據
NSData *data = [clearText dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
//See the doc: For block ciphers, the output size will always be less than or
//equal to the input size plus the size of one block.
//確定加密過後的字元串在內存中存放的大小,根據文檔,對於塊密碼方式(這個庫還包括流密碼方式)
//加密過後的字元串大小總是小於或等於加密之前數據的大小加上對應加密演算法的塊大小
//但看到一些大牛還這樣一下 & ~(kCCBlockSizeDES - 1) 目前不知道為嘛
size_t bufferSize = ([data length] + kCCBlockSizeDES) & ~(kCCBlockSizeDES - 1);
//void *buffer = malloc(bufferSize);//可以手動創建buffer,但之後要記得free掉
unsigned char buffer[bufferSize]; //定義輸出加密串所佔內存空間
memset(buffer, 0, sizeof(char)); //採用ios中宏定義好的方法分配空間,可免去手動free
size_t numBytesEncrypted = 0; //輸出加密串的位元組數
//加密數據,採用庫中的CCCrypt方法,這個方法會按次序執行CCCrytorCreate(),
// CCCryptorUpdate(), CCCryptorFinal(), and CCCryptorRelease() 如果開發者自己create這個對象,
//那麼後面就必須執行final、release之類的函數,CCCrypt方法一次性解決
// Byte iv[] = {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};
//Byte iv[] = {1,2,3,4,5,6,7,8}; 加密所需的隨機字元
CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, //加密方式,kCCEncrypt加密 kCCDecrypt解密
kCCAlgorithmDES, //採用的加密演算法,內置包含AES、DES、
//3DES、其他還有四個,不知道是什麼
//後續討論
//加密額外參數,注意此處各個平台之間指定的時候要記得一樣
kCCOptionPKCS7Padding | kCCOptionECBMode,
[key UTF8String], //加密密匙 UTF8的字元串
kCCKeySizeDES, //密匙長度位元組 各演算法有對應的長度宏
nil, //隨機字元,可指定也可不指定,各平台之間不絕對
[data bytes], //待加密串的位元組長度
[data length], //待加密串的長度
buffer, //輸出已加密串的內存地址
bufferSize, //已加密串的大小
&numBytesEncrypted);
NSString* plainText = nil;
if (cryptStatus == kCCSuccess) {
NSData *dataTemp = [NSData dataWithBytes:buffer length:(NSUInteger)numBytesEncrypted];
plainText = [GTMBase64 stringByEncodingData:dataTemp];
}else{
NSLog(@"DES加密失敗");
}
return plainText;
}
//解密
-(NSString*) decryptUseDES:(NSString*)cipherText key:(NSString*)key {
// 利用 GTMBase64 解碼 Base64 字串
NSData* cipherData = [GTMBase64 decodeString:cipherText];
size_t bufferSize = ([cipherData length] + kCCBlockSizeDES) & ~(kCCBlockSizeDES - 1);
//unsigned char buffer[1024];
unsigned char buffer[bufferSize];
memset(buffer, 0, sizeof(char));
size_t numBytesDecrypted = 0;
// IV 偏移量不需使用
CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt,
kCCAlgorithmDES,
kCCOptionPKCS7Padding | kCCOptionECBMode,
[key UTF8String],
kCCKeySizeDES,
nil,
[cipherData bytes],
[cipherData length],
buffer,
bufferSize,//1024,
&numBytesDecrypted);
NSString* plainText = nil;
if (cryptStatus == kCCSuccess) {
NSData* data = [NSData dataWithBytes:buffer length:(NSUInteger)numBytesDecrypted];
plainText = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
}
return plainText;
}
java和php平台的代碼實現:
Java代碼 收藏代碼
import java.io.IOException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class DES {
private byte[] desKey;
public DES(String desKey) {
this.desKey = desKey.getBytes();
}
public byte[] desEncrypt(byte[] plainText) throws Exception {
SecureRandom sr = new SecureRandom();
byte rawKeyData[] = desKey;
DESKeySpec dks = new DESKeySpec(rawKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance("DES");
cipher.init(Cipher.ENCRYPT_MODE, key, sr);
byte data[] = plainText;
byte encryptedData[] = cipher.doFinal(data);
return encryptedData;
}
public byte[] desDecrypt(byte[] encryptText) throws Exception {
SecureRandom sr = new SecureRandom();
byte rawKeyData[] = desKey;
DESKeySpec dks = new DESKeySpec(rawKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance("DES");
cipher.init(Cipher.DECRYPT_MODE, key, sr);
byte encryptedData[] = encryptText;
byte decryptedData[] = cipher.doFinal(encryptedData);
return decryptedData;
}
public String encrypt(String input) throws Exception {
return base64Encode(desEncrypt(input.getBytes()));
}
public String decrypt(String input) throws Exception {
byte[] result = base64Decode(input);
return new String(desDecrypt(result));
}
public static String base64Encode(byte[] s) {
if (s == null)
return null;
BASE64Encoder b = new sun.misc.BASE64Encoder();
return b.encode(s);
}
public static byte[] base64Decode(String s) throws IOException {
if (s == null)
return null;
BASE64Decoder decoder = new BASE64Decoder();
byte[] b = decoder.decodeBuffer(s);
return b;
}
public static void main(String[] args) throws Exception {
String key = "abcdefgh";
String input = "a";
DES crypt = new DES(key);
System.out.println("Encode:" + crypt.encrypt(input));
System.out.println("Decode:" + crypt.decrypt(crypt.encrypt(input)));
}
}
php 方法一
Php代碼 收藏代碼
<?php
class DES1 {
var $key;
function DES1($key) {
$this->key = $key;
}
function encrypt($input) {
$size = mcrypt_get_block_size('des', 'ecb');
$input = $this->pkcs5_pad($input, $size);
$key = $this->key;
$td = mcrypt_mole_open('des', '', 'ecb', '');
$iv = @mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
@mcrypt_generic_init($td, $key, $iv);
$data = mcrypt_generic($td, $input);
mcrypt_generic_deinit($td);
mcrypt_mole_close($td);
$data = base64_encode($data);
return $data;
}
function decrypt($encrypted) {
$encrypted = base64_decode($encrypted);
$key =$this->key;
$td = mcrypt_mole_open('des','','ecb','');
//使用MCRYPT_DES演算法,cbc模式
$iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
$ks = mcrypt_enc_get_key_size($td);
@mcrypt_generic_init($td, $key, $iv);
//初始處理
$decrypted = mdecrypt_generic($td, $encrypted);
//解密
mcrypt_generic_deinit($td);
//結束
mcrypt_mole_close($td);
$y=$this->pkcs5_unpad($decrypted);
return $y;
}
function pkcs5_pad ($text, $blocksize) {
$pad = $blocksize - (strlen($text) % $blocksize);
return $text . str_repeat(chr($pad), $pad);
}
function pkcs5_unpad($text) {
$pad = ord($text{strlen($text)-1});
if ($pad > strlen($text))
return false;
if (strspn($text, chr($pad), strlen($text) - $pad) != $pad)
return false;
return substr($text, 0, -1 * $pad);
}
}
$key = "abcdefgh";
$input = "a";
$crypt = new DES1($key);
echo "Encode:".$crypt->encrypt($input)."<br/>";
echo "Decode:".$crypt->decrypt($crypt->encr
Ⅶ RC4 php加密後用同樣的密鑰 java無法解密是情況
JAVA是垃圾
Ⅷ 我下載的php文件為什麼打不開
你是要讓你的裝了IIS的機器支持PHP呢還是只是單純的打開*.php的文件?
如果是要支持PHP,那麼你要裝專門的PHP解釋器。
首先你去下載php-4.3.4-Win32.zip。
下面為配置步驟:
1)將php-4.3.3RC4-Win32.zip裡面的所有文件和文件夾解壓縮並放置在C:\\php4\\文件夾中,沒有自己創建該文件夾
2)進入php4文件夾,查看根目錄和子目錄,把所有.dll文件都統統復制粘貼到C:\\WINNT\\system32(WIN2K)或C:\\WINDOWS\\system32(WINXP)中
3)把php4文件夾裡面的php.ini-dist和php.exe文件復制到
C:\\WINNT\\(WIN2K)或C:\\WINDOWS\\(WINXP)中,並將php.ini-dist文件改為php.ini
4)雙擊php.ini打開該配置文件,進行下面3個地方的修改:
1> 把extension_dir = "C:\\php4\\extensions" 改為你安裝php4的 extensions文件夾路徑
2> 把 ;cgi.force_redirect = 1 改為 cgi.force_redirect = 0
3> 把 register_globals = Off 改為 register_globals = On
4> 找到 ;Windows Extensions 段,你應該可以看到如下代碼
;
;extension=php_bz2.dll
;extension=php_cpdf.dll
;extension=php_crack.dll
;extension=php_curl.dll
;extension=php_db.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_dbx.dll
;extension=php_domxml.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_hyperwave.dll
;extension=php_iconv.dll
;extension=php_ifx.dll
;extension=php_iisfunc.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_java.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pdf.dll
;extension=php_pgsql.dll
;extension=php_printer.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_sybase_ct.dll
;extension=php_w32api.dll
;extension=php_xmlrpc.dll
;extension=php_xslt.dll
;extension=php_yaz.dll
;extension=php_zip.dll
具體還得看你需要載入哪些.dll文件,不過你按照下面我這樣改也行,主要是要載入的.dll文件就去掉前面的分號( ; ) :
;
;extension=php_bz2.dll
;extension=php_cpdf.dll
;extension=php_crack.dll
;extension=php_curl.dll
;extension=php_db.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_dbx.dll
;extension=php_domxml.dll
extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_hyperwave.dll
;extension=php_iconv.dll
;extension=php_ifx.dll
;extension=php_iisfunc.dll
extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_java.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pdf.dll
;extension=php_pgsql.dll
;extension=php_printer.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_sybase_ct.dll
;extension=php_w32api.dll
;extension=php_xmlrpc.dll
;extension=php_xslt.dll
;extension=php_yaz.dll
;extension=php_zip.dll
5)再次打開控制面板-管理工具-Internet服務管理器,在"默認web站點"上右鍵單擊,選擇"屬性"
6)選中"默認 Web 站點 屬性"窗口的"主目錄"選項卡,點擊右下角的"配置"按鈕,出現"應用程序配置"窗口,點擊"應用程序映射"下面的"添加"按鈕,添加下面的程序映射:
可執行文件: C:\\php4\\php.exe %s %s (也就是你的php4文件夾路徑)
擴展名: .php
確定完成配置!
7)切換到"默認 Web 站點 屬性"窗口的"ISAPI篩選器"選項卡,點擊右邊的"添加"按鈕,添加下面的一個篩選器:
篩選器名稱: PHP
可執行文件: C:\\php4\\sapi\\php4isapi.dll (也就是你的php4文件夾的 sapi文件夾路徑)
確定後關閉"Internet服務管理器"
8)繼續切換到"默認 Web 站點 屬性"窗口的"文檔"選項卡,點擊右邊的"添加"按鈕,添加如下"啟用默認文檔":
index.php 也可以添加 index.php3 index.php4 等等 看你的需要而定
點擊左邊的"↑"按鈕,把index.php文檔提升到最上面
現在你的IIS也支持PHP了.
Ⅸ php如何對文件進行RC4加密
不清楚。
給文件加密,我使用的是超級加密3000.
超級加密 3000採用先進的加密演算法,使你的文件和文件夾加密後,真正的達到超高的加密強度,讓你的加密數據無懈可擊。