Hi everyone,
I think there’s nobody talked about this,I want to encrypt text for my project,from php(server) to maxscript,encrypt in php,then ,decrypt in maxscript,just text,or a long string,maybe need a little secure,after I searched google,I found there are a lot of examples using C# language,but I really don’t know how to translate them into maxscript,and I don’t know whether it is possible support in maxscript either.What I want is translate below codes to maxscript,I tired several days myself,but unlucky:
origin url:
http://stackoverflow.com/questions/4329260/cross-platform-php-to-c-sharp-net-encryption-decryption-with-rijndael
Below is C# side codes:
public string Decode(string str)
{
byte[] decbuff = Convert.FromBase64String(str);
return System.Text.Encoding.UTF8.GetString(decbuff);
}
static public String DecryptRJ256(string cypher, string KeyString, string IVString)
{
string sRet = "";
RijndaelManaged rj = new RijndaelManaged();
UTF8Encoding encoding = new UTF8Encoding();
try
{
//byte[] message = Convert.FromBase64String(cypher);
byte[] message = encoding.GetBytes(cypher);
byte[] Key = encoding.GetBytes(KeyString);
byte[] IV = encoding.GetBytes(IVString);
rj.Padding = PaddingMode.Zeros;
rj.Mode = CipherMode.CBC;
rj.KeySize = 256;
rj.BlockSize = 256;
rj.Key = Key;
rj.IV = IV;
MemoryStream ms = new MemoryStream(message);
using (CryptoStream cs = new CryptoStream(ms, rj.CreateDecryptor(Key, IV), CryptoStreamMode.Read))
{
using (StreamReader sr = new StreamReader(cs))
{
sRet = sr.ReadToEnd();
}
}
}
finally
{
rj.Clear();
}
return sRet;
}
string temp = DecryptRJ256(Server.UrlDecode(Decode(cypher)), keyString, ivString);
Or does anyone has a better suggestion or solution of encryption/decryption between php and maxscript,thanks.