From e558a783541ecd3ad4e598a6a6f8ea84d51746eb Mon Sep 17 00:00:00 2001 From: arition Date: Tue, 16 Dec 2014 19:47:13 +0800 Subject: [PATCH] Fix error when password is not in English --- SharpCompress/Common/Rar/RarRijndael.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/SharpCompress/Common/Rar/RarRijndael.cs b/SharpCompress/Common/Rar/RarRijndael.cs index 06919c41..a6994839 100644 --- a/SharpCompress/Common/Rar/RarRijndael.cs +++ b/SharpCompress/Common/Rar/RarRijndael.cs @@ -28,11 +28,10 @@ namespace SharpCompress.Common.Rar aesInitializationVector = new byte[CRYPTO_BLOCK_SIZE]; int rawLength = 2 * password.Length; byte[] rawPassword = new byte[rawLength + 8]; - byte[] passwordBytes = Encoding.UTF8.GetBytes(password); - for (int i = 0; i < password.Length; i++) + byte[] passwordBytes = Encoding.Unicode.GetBytes(password); + for (int i = 0; i < rawLength; i++) { - rawPassword[i * 2] = passwordBytes[i]; - rawPassword[i * 2 + 1] = 0; + rawPassword[i] = passwordBytes[i]; } for (int i = 0; i < salt.Length; i++) {