1
イムは、常に両側で同じIVを使用してC#のプログラムから文字列を暗号解除しようとしながら、「悪い解読」を取得します。これは少し迷惑になってきており、実際に問題を把握することはできません。pkcs7の暗号化を解除するには、ルビから256 cbcを差し込みます。
これはRubyコード
def unencrypt(message)
c = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
c.padding = 1
c.decrypt
c.key = key = Digest::SHA1.hexdigest("mytestiv1111111111111111111111111").unpack('a2'*32).map{|x| x.hex}.pack('c'*32)
c.iv = iv = key
e = c.update(Base64.decode64(message))
e << c.final
puts e
end
であり、これは、C#側で暗号化
public string encrypt(string text, //the text to be encrypt
string password,// the encryption key
int cipherindex//The strength of the encryption
)
{
try
{
//get the cipher strength--from cipherindex
CipherKey Key=CipherKey.getCipherKey(cipherindex);
//build and init the Encryptor
RijndaelManaged rijndaelCipher = new RijndaelManaged();
rijndaelCipher.Mode = sCipherMode;
rijndaelCipher.Padding = sPaddingMode;
rijndaelCipher.KeySize = Key.Size;
rijndaelCipher.BlockSize =Key.Size;
byte[] pwdBytes = System.Text.Encoding.UTF8.GetBytes(password);
byte[] keyBytes = new byte[Key.Len];
int len= pwdBytes.Length;
if (len > keyBytes.Length) len= keyBytes.Length;
System.Array.Copy(pwdBytes,keyBytes,len);
rijndaelCipher.Key = keyBytes;
rijndaelCipher.IV = keyBytes;
ICryptoTransform transform = rijndaelCipher.CreateEncryptor();
byte [] plainText = System.Text.Encoding.UTF8.GetBytes(text);
byte[] cipherBytes = transform.TransformFinalBlock(plainText, 0, plainText.Length);
return Convert.ToBase64String(cipherBytes);
}
catch (Exception e)
{
throw;
}
}
任意のアイデアを何ですか?乾杯ダビデは