| |

VerySource

 Forgot password?
 Register
Search
View: 1467|Reply: 13

Urgent: Question about DES encryption and decryption.

[Copy link]

1

Threads

7

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-5 10:50:01
| Show all posts |Read mode
public string Decrypt (string pToDecrypt, string sKey)
{
DESCryptoServiceProvider provider1 = new DESCryptoServiceProvider ();
byte [] buffer1 = new byte [pToDecrypt.Length / 2];
for (int num1 = 0; num1 <(pToDecrypt.Length / 2); num1 ++)
{
int num2 = Convert.ToInt32 (pToDecrypt.Substring (num1 * 2, 2), 0x10);
buffer1 [num1] = (byte) num2;
}
provider1.Key = Encoding.ASCII.GetBytes (sKey);
provider1.IV = Encoding.ASCII.GetBytes (sKey);
MemoryStream stream1 = new MemoryStream ();
CryptoStream stream2 = new CryptoStream (stream1, provider1.CreateDecryptor (), CryptoStreamMode.Write);
stream2.Write (buffer1, 0, buffer1.Length);
stream2.FlushFinalBlock ();
StringBuilder builder1 = new StringBuilder ();
return Encoding.Default.GetString (stream1.ToArray ());
}
==================================================
The above is the method of decryption.
The call is this: This.Decrypt ("48FC50F3F5EB1A4B9CF9FA16765A4812", "2% b <5X7 *");
"48FC50F3F5EB1A4B9CF9FA16765A4812" is the encrypted character of "127.0.0.1"
"2% b <5X7 *" is KEY

What I want to ask is this: "48FC50F3F5EB1A4B9CF9FA16765A4812"
It came through encryption. His length is 32 bits. I don't know how it was encrypted!
Can anyone tell me how I can achieve this effect?

I wrote an encryption myself
public string Encryptor (string pToEncryptor, string sKey)
{
DESCryptoServiceProvider provider1 = new DESCryptoServiceProvider ();

byte [] buffer1 = ASCIIEncoding.Default.GetBytes (pToEncryptor);

provider1.Key = Encoding.ASCII.GetBytes (sKey);
provider1.IV = Encoding.ASCII.GetBytes (sKey);
MemoryStream stream1 = new MemoryStream ();
CryptoStream stream2 = new CryptoStream (stream1, provider1.CreateEncryptor (), CryptoStreamMode.Write);
stream2.Write (buffer1, 0, buffer1.Length);
stream2.FlushFinalBlock ();
StringBuilder builder1 = new StringBuilder ();
return Encoding.Default.GetString (stream1.ToArray ());
}

But the String that comes out is a bunch of Strings that don't know what
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-5 13:45:02
| Show all posts
Convert each byte of stream1.ToArray () into a hexadecimal number, and then concatenate
Reply

Use magic Report

1

Threads

7

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-1-5 14:33:01
| Show all posts
Why is the fixed length of 127.0.0.1 or any other characters encrypted: 32
This is very depressing. .
Reply

Use magic Report

0

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-5 16:00:01
| Show all posts
Hash it out.
Reply

Use magic Report

1

Threads

7

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-1-5 16:24:01
| Show all posts
It doesn't seem to work now. . .
public string Encryptor (string pToEncryptor, string sKey)
{
DESCryptoServiceProvider provider1 = new DESCryptoServiceProvider ();

byte [] buffer1 = ASCIIEncoding.Default.GetBytes (pToEncryptor);

provider1.Key = Encoding.ASCII.GetBytes (sKey);
provider1.IV = Encoding.ASCII.GetBytes (sKey);
MemoryStream stream1 = new MemoryStream ();
CryptoStream stream2 = new CryptoStream (stream1, provider1.CreateEncryptor (), CryptoStreamMode.Write);
stream2.Write (buffer1, 0, buffer1.Length);
stream2.FlushFinalBlock ();
StringBuilder builder1 = new StringBuilder ();
string n = null;
for (int i = 0; i <stream1.ToArray (). Length; i ++)
{
n + = Convert.ToInt32 ((stream1.ToArray ()) [i]). ToString ();
}
Ranch
return n;
}
Reply

Use magic Report

1

Threads

7

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-1-5 16:42:02
| Show all posts
Which master can write me all encryption methods
Put
string = 127.0.0.1
key = "2% b <5X7 *"
Encrypted into "48FC50F3F5EB1A4B9CF9FA16765A4812"
Reply

Use magic Report

0

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-5 17:15:01
| Show all posts
// byte [] Data = Encoding.ASCII.GetBytes ("IrisSkin is good !!!");
                
// sha1 crypto service, digital signatures are created from the hash
                // string datastr = Convert.ToBase64String (Data);

// DSA-SHA1 algorithm
                

if (! SkinEngine.DSA.VerifyData (SkinEngine.DSAHash, Convert.FromBase64String (base.Engine.SerialNumber)))

byte [] SignedValue = Convert.FromBase64String ("flcRzsRtDNr2XBiCoY7NrAC352AiFA / 4YuLs4nDCyOHZX5xvWtgH / g ==");
textBox1.Text = Convert.ToBase64String (SignedValue);



this.Text = dsa.VerifyData (Data, SignedValue) .ToString ();
Reply

Use magic Report

0

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-5 17:27:01
| Show all posts
System.Security.Cryptography.DSACryptoServiceProvider dsa = new DSACryptoServiceProvider ();

DSAParameters p = new DSAParameters ();
p.Counter = 31;
p.X = Convert.FromBase64String ("SXJpc1NraW4gaXMgZ29vZCAhISE =");
p.P = Convert.FromBase64String ("v7aWx402hheC7WRlmLBlBE / DL3CI8b / Vmj / dCEQRMao1kVRmGL / fWhJGrnQUg4OU / cISGW1 + DSu / iIhSKBZV4Q ==");
p.Q = Convert.FromBase64String ("qRjCfkW / dk6mL4iUSTb5dZTKx30 =");
p.G = Convert.FromBase64String ("aXWT + c / HfeIDCPzilyuoMXd1tHV3n1uiBa35dDRZqZ25o9PmMtaeHIBZAGPik5 / qhDGf + sGm76QAGs5PzmM3dA ==");
p.Seed = Convert.FromBase64String ("Z7UfhiqEbRBHn4yq4GYjuX / XMFI =");
Ranch
dsa.ImportParameters (p);
Reply

Use magic Report

1

Threads

7

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-1-5 18:24:01
| Show all posts
string text1 = "abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789` ~! @ # $% ^&* () _ + |-= [] {}; ': <>?,. /";
                        string text2 = text1.Substring (0x36, 1) + text1.Substring (0x44, 1) + text1.Substring (1, 1) + text1.Substring (0x56, 1) + text1.Substring (0x39, 1) + text1. Substring (0x31, 1) + text1.Substring (0x3b, 1) + text1.Substring (0x47, 1);
                        string text3 = _Default.Decrypt (SifuData.UserDn (), text2);
                        string text4 = _Default.Decrypt ("48FC50F3F5EB1A4B9CF9FA16765A4812", text2);
                        string text5 = _Default.Decrypt ("24D673EB0598C4C8CD7A07F2B31E321B", text2);
                        string text6 = base.Request.Url.AbsoluteUri.ToLower ();

This one is similar to what was written upstairs.
"abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789` ~! @ # $% ^&* () _ + |-= [] {}; ': <>?,. /"

The code you gave me upstairs is getting more and more confused. .
Can you help me write the method in full?
Reply

Use magic Report

1

Threads

7

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-1-5 18:27:01
| Show all posts
string text1 = "abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789` ~! @ # $% ^&* () _ + |-= [] {}; ': <>?,. /";
                        string text2 = text1.Substring (0x36, 1) + text1.Substring (0x44, 1) + text1.Substring (1, 1) + text1.Substring (0x56, 1) + text1.Substring (0x39, 1) + text1. Substring (0x31, 1) + text1.Substring (0x3b, 1) + text1.Substring (0x47, 1);
                        string text3 = _Default.Decrypt (SifuData.UserDn (), text2);
                        string text4 = _Default.Decrypt ("48FC50F3F5EB1A4B9CF9FA16765A4812", text2);
                        string text5 = _Default.Decrypt ("24D673EB0598C4C8CD7A07F2B31E321B", text2);
                        string text6 = base.Request.Url.AbsoluteUri.ToLower ();

This one is similar to what was written upstairs.
"abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789` ~! @ # $% ^&* () _ + |-= [] {}; ': <>?,. /"

The code you gave me upstairs is getting more and more confused. .
Can you help me write the method in full?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list