Transfer from http://www.cnblogs.com/zhuiyi/archive/2013/04/01/2993201.htmlRecently by Des plus decryption made super depressed, I use C # method to encrypt the ciphertext is always with the client to the Java encryption ciphertext different, find a lot of information has not been solved. I didn't solve the problem until I saw the above blog post. Mark here to avoid forgetting!Let's start with a C # version
In the previous introduction of the use of some encryption and decryption classes, here combined to do a simple test, the code is as follows:
Mainactivity:
Copy Code code as follows:
Package com.home.testdes;
Import Android.os.Bundle;Import Android.util.Log;Import android.app.Activity;
public class Mainactivity extends activity {
@Overrideprotected void OnCreate (Bundle savedinstancestate) {Super.oncreate (savedinstancest
The company's Protocol security requirements require des and md5 encryption for the transmitted content. This is because I was a newbie and was a little dizzy when I handed it over to me. We started to find various des encrypted content on the Internet. Because I don't understand it, I think I need to understand the principles, and finally I am confused by the ti
Original: PHP implementation and C # consistent DES encryption and decryptionPHP implementation and C # consistent DES encryption decryption, can be searched from the internet to a large heap, but the test found no use. The following are the correct codes that I found after a hard struggle. I hope you can use it when t
Encryption in the Web site using cookies or storing data to the database often use encryption and decryption, MD5 very useful, but sometimes need to inverse. Then the DES symmetric encryption is more useful. Set a key, and then encrypt all the data. Code introduction as follows, the prior declaration only for the young
Des plus decryption algorithms, common classes in C # and PHP.
Attention:
1. The key in the class is the same value as the Vector IV.
2, the code is used Utf-8
The following is the specific code, can be copied directly to carry out the actual test
C # version Code:
Using System; Using System.Data; Using System.Configuration; Using System.Web; Using System.Web.Security; Using System.Web.UI; Using System.Web.UI.WebControls; Using System.
PHP and C # consistent DES Encryption and decryption algorithm class sharing
Des plus decryption algorithms, common classes in C # and PHP.
Attention:
1. The key in the class is the same value as the Vector IV.
2, the code is used Utf-8
The following is the specific code, can be copied directly to carry out the actual test
C # version Code:
Using System; Usin
plaintext = integer.tohexstring (0xFF B[i]);if (Plaintext.length () plaintext = "0" + plaintext;Hexstring.append (plaintext);}
return hexstring.tostring ();}
}
. NET version
Copy Code code as follows:
Using System;
Using System.Data;
Using System.Configuration;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
Using System.Data.SqlClient;
Us
Des is a 16-wheeled Feistel structure cipher with a packet length of 64 bits, a 56-bit key to encrypt a 64-bit plaintext string, and a 64-bit cipher string. Where the key is 64 bits, the utility is 56 bits, and the other 8 bits are used as parity. The process of encryption is the first 64-bit plaintext group initial replacement, then the left and right two parts after 16 rounds of iterations, and then the c
. For more information, seeCopy codeThe Code is as follows: C # And javascript can be used to teach encryption and decryption functions.Des encryption and decryption implemented in C:Protected void page_load (Object sender, eventargs E){String data = "testdes"; // data to be encryptedByte [] _ DATA = system. Text. encoding. Unicode. getbytes (data );String keystr = "1234"; // keyString ivstr = "ABCD"; // in
Reference namespace requiredusing System; using System.Text; using System.Security.Cryptography; using System.IO;Specific code:1 Public classCryptohelper2 {3 /// 4 ///using DES encryption5 /// 6 /// plaintext7 /// encryption Key8 /// Vector9 /// back to RedactionTen Public Static stringDesencode (stringPlainstringKeystringIV) One
. NET version
PHP version
Class des{var $key; var $iv; Offset function DES ($key, $iv =0) {//key length 8 for example: 1234ABCD $this->key = $key; if ($iv = = 0) {$this->iv = $key;//default to $key as IV} else {$this->iv = $iv;//mcrypt_c Reate_iv (Mcrypt_get_block_size (Mcrypt_des, MCRYPT_MODE_CBC), mcrypt_dev_random); }} function Encryp
Package Encrypt;import java.security.*; Import javax.crypto.*; Import sun.misc.*;/** * Using DES encryption and decryption, the byte[],string type can be encrypted and decrypted * ciphertext can be stored using string,byte[]. * Method: * void GetKey (string strkey) generates a key from strkey Note * String getencstring (string strming) to encrypt strming , returns a string cipher * string getdesstrin
Reprint please indicate source: http://www.cnblogs.com/gexun/p/3705207.html, thank you.These days have been doing a knowledge question and answer project, because the preliminary project topic is relatively small, so the title is written in the local plist file, directly read it.The company PM worry about the problem leaked, so we have to give plist file encryption, this can put me disabled, because I have never done
Note: For des encryption and decryption, php and. net implementation php5.x, you need to add php extension php_mcrypt.
1 class STD3Des 2 {3 private $ key = ""; 4 private $ iv = ""; 5 6/** 7 * structure, pass two keys with base64_encode and IV 8*9 * @ param string $ key10 * @ param string $ iv11 */12 function _ construct ($ KEY, $ iv) 13 {14 if (empty ($ key) | empty ($ iv) {15 echo 'key and iv is not va
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.