BLOG ARTICLE 복호화 | 2 ARTICLE FOUND

  1. 2009/03/04 자바스크립트 암호화/ 복호화
  2. 2008/07/07 문자열 DES 암호화/복호화

간단하게 웹 페이지 하나 만들 일이 생겼는데,
자바 스크립트 좀 훔쳐 볼랬더니 js 파일이 암호화 되어 있다.
하나 하나 만들기 무진장 빡세다 ;;
혹시나 해서 찾아 보니 이런게 있군하~ ㅋㅋ


Encode

 screnc 원본파일 암호화파일

Decode

 scrdec 원본파일 복호화파일 -cp 949




[출처] JScript.Encode 복호화|작성자 니꽁


private static Byte[] ConvertStringToByteArray(String s)
{
           return (new UnicodeEncoding()).GetBytes(s);
}

## 암호화

private void encodingFunction()
{
FileStream fs = new FileStream("filename.cfg", FileMode.Create, FileAccess.Write);
String strinput = "암호화할 문자열";
Byte[] bytearrayinput = ConvertStringToByteArray(strinput);

//DES instance with random key
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
//create DES Encryptor from this instance
ICryptoTransform desencrypt = des.CreateEncryptor(ConvertStringToByteArray("1111"), ConvertStringToByteArray("2222"));

//Create Crypto Stream that transforms file stream using des encryption
CryptoStream cryptostream = new CryptoStream(fs, desencrypt, CryptoStreamMode.Write);

//write out DES encrypted file
cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length);
cryptostream.Close();

fs.Close();
}



## 복호화
private void decodingFunction()
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
//create file stream to read encrypted file back
FileStream fsread = new FileStream("filename.cfg", FileMode.Open, FileAccess.Read);

//create DES Decryptor from our des instance
ICryptoTransform desdecrypt = des.CreateDecryptor(ConvertStringToByteArray("1111"), ConvertStringToByteArray("2222"));

//create crypto stream set to read and do a des decryption transform on incoming bytes
CryptoStream cryptostreamDecr = new CryptoStream(fsread, desdecrypt, CryptoStreamMode.Read);
//print out the contents of the decrypted file

 StreamReader sr = new StreamReader(cryptostreamDecr, new UnicodeEncoding());
while (!sr.EndOfStream)
{
  cmbPrefix.Items.Add(sr.ReadLine());
}
fsread.Close();
}