using System.Security.Cryptography;
internal class EncryptDecrypt
private string encryptionKey = "OT0XSA11XONHIXWLD4QQNEBOXKHK97WQK2525F02QAT3V72LQITWMP31Y5H8NMBNKKUXS3HVL7IFFG3SYRE0PKRLKC";
private string initVector = "UP74OYTLD9782MFDA0W6SWVTSB3KHR458GFXHIQ0GQBAXP1R40THSK3V5615W41FDI4TKM87TR7YGA40PNXN4BKCTN";
public string DecryptString(string stringToDecrypt)
byte[] numArray = new byte[stringToDecrypt.Length];
int startIndex = (int) this.encryptionKey[1] - 32;
this.key = Encoding.UTF8.GetBytes(this.encryptionKey.Substring(startIndex, 8));
this.IV = Encoding.UTF8.GetBytes(this.initVector.Substring(startIndex, 8));
DESCryptoServiceProvider cryptoServiceProvider = new DESCryptoServiceProvider();
using (MemoryStream memoryStream = new MemoryStream())
using (CryptoStream cryptoStream = new CryptoStream((Stream) memoryStream, cryptoServiceProvider.CreateDecryptor(this.key, this.IV), CryptoStreamMode.Write))
byte[] buffer = Convert.FromBase64String(stringToDecrypt);
cryptoStream.Write(buffer, 0, buffer.Length);
cryptoStream.FlushFinalBlock();
return Encoding.UTF8.GetString(memoryStream.ToArray());
public string EncryptString(string originalString)
byte[] numArray = new byte[originalString.Length];
int startIndex = (int) this.encryptionKey[1] - 32;
this.key = Encoding.UTF8.GetBytes(this.encryptionKey.Substring(startIndex, 8));
this.IV = Encoding.UTF8.GetBytes(this.initVector.Substring(startIndex, 8));
if (String.IsNullOrEmpty(originalString))
throw new ArgumentNullException
("The string which needs to be encrypted can not be null.");
DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream,
cryptoProvider.CreateEncryptor(this.key, this.IV), CryptoStreamMode.Write);
StreamWriter writer = new StreamWriter(cryptoStream);
writer.Write(originalString);
cryptoStream.FlushFinalBlock();
return Convert.ToBase64String(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
public string EncryptStringClean(string originalString)
byte[] numArray = new byte[originalString.Length];
int startIndex = (int) this.encryptionKey[1] - 32;
this.key = Encoding.UTF8.GetBytes(this.encryptionKey.Substring(startIndex, 8));
this.IV = Encoding.UTF8.GetBytes(this.initVector.Substring(startIndex, 8));
DESCryptoServiceProvider cryptoServiceProvider = new DESCryptoServiceProvider();
using (MemoryStream memoryStream = new MemoryStream())
using (CryptoStream cryptoStream = new CryptoStream((Stream) memoryStream, cryptoServiceProvider.CreateEncryptor(this.key, this.IV), CryptoStreamMode.Write))
StreamWriter writer = new StreamWriter(cryptoStream);
writer.Write(originalString);
cryptoStream.FlushFinalBlock();
return Convert.ToBase64String(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
public void EncryptString2(string stringToDecrypt)
string original = stringToDecrypt;
using (AesCryptoServiceProvider myAes = new AesCryptoServiceProvider())
byte[] numArray = new byte[stringToDecrypt.Length];
int startIndex = (int) this.encryptionKey[1] - 32;
this.key = Encoding.UTF8.GetBytes(this.encryptionKey.Substring(startIndex, 8));
this.IV = Encoding.UTF8.GetBytes(this.initVector.Substring(startIndex, 8));
byte[] b = System.Text.ASCIIEncoding.ASCII.GetBytes("0012099-12-12 00:00:00Nop.Plugin.Shipping.Director www.hsdgo.com");
string buffer = Convert.ToBase64String(b);
byte[] encrypted = EncryptStringToBytes_Aes(buffer, this.key, this.IV);
string roundtrip = DecryptStringFromBytes_Aes(encrypted, this.key, this.IV);
Console.WriteLine("Original: {0}", original);
Console.WriteLine("Round Trip: {0}", roundtrip);
static byte[] EncryptStringToBytes_Aes(string plainText, byte[] Key, byte[] IV)
if (plainText == null || plainText.Length <= 0)
throw new ArgumentNullException("plainText");
if (Key == null || Key.Length <= 0)
throw new ArgumentNullException("Key");
if (IV == null || IV.Length <= 0)
throw new ArgumentNullException("IV");
using (AesCryptoServiceProvider aesAlg = new AesCryptoServiceProvider())
ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
using (MemoryStream msEncrypt = new MemoryStream())
using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
swEncrypt.Write(plainText);
encrypted = msEncrypt.ToArray();
static string DecryptStringFromBytes_Aes(byte[] cipherText, byte[] Key, byte[] IV)
if (cipherText == null || cipherText.Length <= 0)
throw new ArgumentNullException("cipherText");
if (Key == null || Key.Length <= 0)
throw new ArgumentNullException("Key");
if (IV == null || IV.Length <= 0)
throw new ArgumentNullException("IV");
using (AesCryptoServiceProvider aesAlg = new AesCryptoServiceProvider())
ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
using (MemoryStream msDecrypt = new MemoryStream(cipherText))
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
plaintext = srDecrypt.ReadToEnd();
public static void Main()
string test = new EncryptDecrypt().DecryptString("Yt3nLGIK3R3CJhL/0i2dsaj4Ww5q1t3NZ9mFbn0TztWcF32h7UM9/yFckkTmV3VZp2z03fjphwilmpE2IR9KIxYDUd49pcNb");
string strHSDGO = new EncryptDecrypt().DecryptString("Yt3nLGIK3R3CJhL/0i2dsaj4Ww5q1t3NZ9mFbn0TztWcF32h7UM9/yFckkTmV3VZp2z03fjphwilmpE2IR9KIxYDUd49pcNb");
string strBHwww = new EncryptDecrypt().DecryptString("Yt3nLGIK3R3CJhL/0i2dsaj4Ww5q1t3NZ9mFbn0TztWcF32h7UM9/yFckkTmV3VZp2z03fjphwgCxCBZJtTLiee2OwxcgG7C");
string strBH = new EncryptDecrypt().DecryptString("pqX5GeO73tMRLG1MW38n12ebx20a0RGRxKc3Goc1thhINePXI8fz9uo2/BtA15+qcQEZy8O+q9/L0l+kmkmUkcB4IEwZqIrv");
string strBHP = new EncryptDecrypt().DecryptString("pqX5GeO73tMRLG1MW38n12ebx20a0RGRxKc3Goc1thjsrElPY/1CEISypXkhjAm1KSk0iErU/hfb8PqwZGhKY98KzI8e8NRo");
string strSeaS = new EncryptDecrypt().DecryptString("pqX5GeO73tMRLG1MW38n12ebx20a0RGRxKc3Goc1thhINePXI8fz9uo2/BtA15+q9+Dn7H2zzyT+chnqubz5Qw==");
string strSeaP = new EncryptDecrypt().DecryptString("pqX5GeO73tMRLG1MW38n12ebx20a0RGRxKc3Goc1thjsrElPY/1CEISypXkhjAm1He2ri50g6Emd1xZaYkRwGw==");
string strSeaSbhuat = new EncryptDecrypt().DecryptString("SNXVw2VGIV7hJX3RjkHJLZCdRPwKvn1nW0EEOkm9jd78qez1rWDuZIXVBZroP67F6Mi51/Adr5nM5MXwLxcP2rtYvmOBgo2H");
string strSeaPbhuat = new EncryptDecrypt().DecryptString("SNXVw2VGIV7hJX3RjkHJLZCdRPwKvn1nW0EEOkm9jd7UWieCA7/DpyL+bgVmSt2L9sS9UH1QB+xn3ATng1bwHZTyl0oSnylH");
string strNopBHS = new EncryptDecrypt().DecryptString("SNXVw2VGIV7hJX3RjkHJLZCdRPwKvn1nW0EEOkm9jd78qez1rWDuZIXVBZroP67FcMIm9CwYlreNZ63gAW9BWgJggByPVG38");
string strNopBHP = new EncryptDecrypt().DecryptString("SNXVw2VGIV7hJX3RjkHJLZCdRPwKvn1nW0EEOkm9jd7UWieCA7/DpyL+bgVmSt2L9sS9UH1QB+xnYRJ0PfHr89VUhbj4qxbSXM+peYFZE7o=");
string strNopLocalS = new EncryptDecrypt().DecryptString("SNXVw2VGIV7hJX3RjkHJLZCdRPwKvn1nW0EEOkm9jd78qez1rWDuZIXVBZroP67FIuTDbVU1DV80uwmRkfBR/w==");
string bufferHSDGO = new EncryptDecrypt().EncryptStringClean("0012099-12-12 00:00:00Nop.Plugin.Shipping.Director www.hsdgo.com");
string bufferBHwww = new EncryptDecrypt().EncryptStringClean("0012099-12-12 00:00:00Nop.Plugin.Shipping.Director www.bananahobby.com");
string bufferBH = new EncryptDecrypt().EncryptStringClean("0022099-12-12 00:00:00Nop.Plugin.Shipping.Director bananahobby.com");
string bufferBHP = new EncryptDecrypt().EncryptStringClean("0022099-12-12 00:00:00Nop.Plugin.Payment.Director bananahobby.com");
string bufferSeaS = new EncryptDecrypt().EncryptStringClean("0022099-12-12 00:00:00Nop.Plugin.Shipping.Director www.sea.sg");
string bufferSeaP = new EncryptDecrypt().EncryptStringClean("0022099-12-12 00:00:00Nop.Plugin.Payment.Director www.sea.sg");
string bufferSeaSbhuat = new EncryptDecrypt().EncryptStringClean("0022999-12-12 00:00:00Nop.Plugin.Shipping.Director bh-uat.sea.sg");
string bufferSeaPbhuat = new EncryptDecrypt().EncryptStringClean("0022999-12-12 00:00:00Nop.Plugin.NopTools.PaymentDirectorbh-uat.sea.sg");
string bufferNopBHS = new EncryptDecrypt().EncryptStringClean("0022999-12-12 00:00:00Nop.Plugin.Shipping.Director bananahobby.com");
string bufferNopBHP = new EncryptDecrypt().EncryptStringClean("0022999-12-12 00:00:00Nop.Plugin.NopTools.PaymentDirectorbananahobby.com");
string bufferNopLocalS = new EncryptDecrypt().EncryptStringClean("0022999-12-12 00:00:00Nop.Plugin.Shipping.Director localhost");
DateTime dateTime = DateTime.Parse(test.Substring(3, 19));
var gogo = strSeaPbhuat.Substring(57);
string source = strBH.Substring(52);
Console.WriteLine("************************************************************************************************************");
Console.WriteLine(strHSDGO);
Console.WriteLine(bufferHSDGO);
Console.WriteLine("************************************************************************************************************");
Console.WriteLine(strBHwww);
Console.WriteLine(bufferBHwww);
Console.WriteLine("************************************************************************************************************");
Console.WriteLine(strBH);
Console.WriteLine(bufferBH);
Console.WriteLine("************************************************************************************************************");
Console.WriteLine(strBHP);
Console.WriteLine(bufferBHP);
Console.WriteLine("************************************************************************************************************");
Console.WriteLine(strSeaS);
Console.WriteLine(bufferSeaS);
Console.WriteLine("************************************************************************************************************");
Console.WriteLine(strSeaP);
Console.WriteLine(bufferSeaP);
Console.WriteLine("************************************************************************************************************");
Console.WriteLine(strSeaSbhuat);
Console.WriteLine(bufferSeaSbhuat);
Console.WriteLine("************************************************************************************************************");
Console.WriteLine(strSeaPbhuat);
Console.WriteLine(bufferSeaPbhuat);
Console.WriteLine("************************************************************************************************************");
Console.WriteLine(strNopBHS);
Console.WriteLine(bufferNopBHS);
Console.WriteLine("************************************************************************************************************");
Console.WriteLine(strNopBHP);
Console.WriteLine(bufferNopBHP);
Console.WriteLine("--------------------------------localhost Shipping---------------------------------------------");
Console.WriteLine(strNopLocalS);
Console.WriteLine(bufferNopLocalS);
Console.WriteLine("************************************************************************************************************");
Console.WriteLine(dateTime.ToString());
Console.WriteLine(source);