<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум Guardant &mdash; Строковый вектор инициализации]]></title>
	<link rel="self" href="https://forum.guardant.ru/feed/atom/topic/18" />
	<updated>2011-12-26T09:08:01Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.guardant.ru/topic/18/</id>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/620/#p620" />
			<content type="html"><![CDATA[<p>После двухнедельной переписке с тех.поддержкой, особая благодарность Антону Тихиенко, пишу как правильно нужно было конвертировать строку unicode в переменную типа long:<br /></p><div class="codebox"><pre><code>UnicodeEncoding unicode = new UnicodeEncoding();
Byte[] b1 = unicode.GetBytes(sKey);
Int64 InitVectorGS2 = System.BitConverter.ToInt64(b1, 0); </code></pre></div><p>где sKey - вектор инициализации типа string.</p>]]></content>
			<author>
				<name><![CDATA[Dmitriy]]></name>
				<uri>https://forum.guardant.ru/user/26/</uri>
			</author>
			<updated>2011-12-26T09:08:01Z</updated>
			<id>https://forum.guardant.ru/post/620/#p620</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/607/#p607" />
			<content type="html"><![CDATA[<p>Алексей, здравствуйте, старая проблема дала о себе знать вновь. <br />В предыдущий раз вопрос решился путем преобразования вектора инициализации в Unicode&nbsp; и использования первых 8-ми байт в GrdCrypt(). Так случилось, что в качестве вектора инициализации были выбраны 4 идентичных символа, как в данном посте так и в некотором количестве случаев в наших проектах. По чистой случайности вчера был сгенерирован вектор, состоящий из 4 различных чисел: <strong>3556</strong>. Согласно решению, это значение было преобразовано в Unicode:<strong>0x0033003500350036</strong> это значение и передалось в&nbsp; GrdCrypt() - <span class="bbu">ожидаемое расшифрованное значение оказалось неверным</span>. <br />Начал разбираться, нашел закономерность: если все числовые символы вектора инициализации идентичны:&quot;1111&quot;(<em>Unicode:0x0031003100310031</em>),&quot;2222&quot;(<em>Unicode:0x0032003200320032</em>),&quot;3333&quot;(<em>Unicode:0x0033003300330033</em>),........&quot;9999&quot;(<em>Unicode:0x0039003900390039</em>) - расшифрованное значение корректно, в остальных случаях расшифровка возвращает неверный результат, вопрос, почему, как это можно объяснить?</p>]]></content>
			<author>
				<name><![CDATA[Dmitriy]]></name>
				<uri>https://forum.guardant.ru/user/26/</uri>
			</author>
			<updated>2011-12-08T21:14:23Z</updated>
			<id>https://forum.guardant.ru/post/607/#p607</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/476/#p476" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Алексей Перепелов пишет:</cite><blockquote><p>в Rad-студии и Delphi 7 компилировался один и тот же исходник. Результаты разные.</p></blockquote></div><p>Не мудрено, ведь в RAD 2010 string уже 2-х байтовый юникод.</p>]]></content>
			<author>
				<name><![CDATA[IMT]]></name>
				<uri>https://forum.guardant.ru/user/99/</uri>
			</author>
			<updated>2011-10-09T18:12:54Z</updated>
			<id>https://forum.guardant.ru/post/476/#p476</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/149/#p149" />
			<content type="html"><![CDATA[<p>Теперь все однозначно ясно, еще раз хочу поблагодарить Вас за помощь в решения данной проблемы.<br /></p><div class="quotebox"><cite>Алексей Перепелов пишет:</cite><blockquote><p>2. Написал. А с ним разве что-то не так?</p></blockquote></div><p>сам алгоритм интересен,никогда не приходилось конвертировать строку в число, чтобы конвертируемое значение и результат были эквивалентными.</p>]]></content>
			<author>
				<name><![CDATA[Dmitriy]]></name>
				<uri>https://forum.guardant.ru/user/26/</uri>
			</author>
			<updated>2011-05-19T08:32:00Z</updated>
			<id>https://forum.guardant.ru/post/149/#p149</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/147/#p147" />
			<content type="html"><![CDATA[<p>1.</p><p>ACSII:<br /></p><div class="codebox"><pre><code>&#039;1&#039; == 0x31
&#039;\0&#039; == 0x00
&quot;11111111&quot; == 0x31 0x31 0x31 0x31 0x31 0x31 0x31 0x31 0x00
&quot;1\01\01\01\0&quot; == 0x31 0x00 0x31 0x00 0x31 0x00 0x31 0x00 0x00 </code></pre></div><p>unicode:<br /></p><div class="codebox"><pre><code>&#039;1&#039; == 0x0031 == 0x31 0x00 
&quot;1111&quot; == 0x31 0x00 0x31 0x00 0x31 0x00 0x31 0x00 0x00 0x00 </code></pre></div><p>Int64:<br /></p><div class="codebox"><pre><code>0x0031003100310031 == 0x31 0x00 0x31 0x00 0x31 0x00 0x31 0x00</code></pre></div><p>2. Написал. А с ним разве что-то не так?</p>]]></content>
			<author>
				<name><![CDATA[Алексей Перепелов]]></name>
				<uri>https://forum.guardant.ru/user/6/</uri>
			</author>
			<updated>2011-05-19T08:07:41Z</updated>
			<id>https://forum.guardant.ru/post/147/#p147</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/146/#p146" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Алексей Перепелов пишет:</cite><blockquote><p>Int64 initVectorGS2 = 0x0031003100310031</p></blockquote></div><p>Наконец расшифровалась строка!!!!! Огромнейшая благодарность от нашей команды разработчиков! Остались некоторые неясности:<br /><strong>1-</strong> &quot;1&quot; в unicode это 0031 - вопросов тут нет.<br />Не могу найти логику преобразования <em>11111111</em> = <em>1\01\01\01\0</em> or <em>0x0031003100310031</em>???<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |________________________________|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;V&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;каким образом&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; получаются такие форматы значений?<br />вариант с видом &quot;0031003100310031&quot; - вектор 8ми байтный, но unicode каждый символ 2-ух байтный,выходит используем 1-е 4 символа, не ясно тогда как Вы пришли к виду &quot;1\01\01\01\0&quot;?<br /><strong>2-</strong>откуда Вы взяли алгоритм по преобразованию строки в int64 (Int64 result = v[0] * ((Int64)1 &lt;&lt; 0) + v[1] * ((Int64)1 &lt;&lt; 8) + v[2] * ((Int64)1 &lt;&lt; 16) + v[3] * ((Int64)1 &lt;&lt; 24) + v[4] * ((Int64)1 &lt;&lt; 32) + v[5] * ((Int64)1 &lt;&lt; 40) + v[6] * ((Int64)1 &lt;&lt; 48) + v[7] * ((Int64)1 &lt;&lt; 56);)?</p>]]></content>
			<author>
				<name><![CDATA[Dmitriy]]></name>
				<uri>https://forum.guardant.ru/user/26/</uri>
			</author>
			<updated>2011-05-18T14:24:24Z</updated>
			<id>https://forum.guardant.ru/post/146/#p146</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/140/#p140" />
			<content type="html"><![CDATA[<p>Дмитрий,<br />когда я говорил о том, как выглядит юникод строка из единиц, я имел в виду ее представление в памяти.<br />Вместо использования FromStringToInt64(&quot;1\01\01\01\0&quot;) можете сразу присвоить Int64 initVectorGS2 = 0x0031003100310031.</p><p>Более длинным (как Ваш unicodeVector) делать вектор инициализации не имеет смысла, так как реально используются только первые 8 байт (согласно документации).</p><p>Что касается других вопросов по программированию, то лучше чем я ответы на них подскажет MSDN.</p>]]></content>
			<author>
				<name><![CDATA[Алексей Перепелов]]></name>
				<uri>https://forum.guardant.ru/user/6/</uri>
			</author>
			<updated>2011-05-18T11:35:39Z</updated>
			<id>https://forum.guardant.ru/post/140/#p140</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/139/#p139" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Алексей Перепелов пишет:</cite><blockquote><p>...выглядит как 0x31 0x00 0x31 0x00 0x31 0x00 ....</p></blockquote></div><p>нужно было еще в 16-ый вид перевести:<br /></p><div class="codebox"><pre><code>.......
            string unicodeVector = &quot;&quot;;
            UnicodeEncoding unicode = new UnicodeEncoding();
            Byte[] b = unicode.GetBytes(sInitVector);
            foreach (byte bb in b)
            {
                unicodeVector = unicodeVector + string.Format(&quot;{0:x}&quot;, bb);//получаем 16-ное представление unicoda
            }
...........</code></pre></div><p>в итоге получаем <strong>unicodeVector=310310310310310310310310</strong>, перед расшифровкой данных передаем его в FromStringToInt64(), где получаем исключение в строке: </p><div class="codebox"><pre><code>.....e.GetBytes(szInitVectorGS2, 0, szInitVectorGS2.Length, v, 0);.......</code></pre></div><p><em>Буфер выходных байт не достаточен для хранения закодированных данных, <br />кодирование &quot;US-ASCII&quot; резерв &quot;System.Text.EncoderReplacementFallback&quot;.<br />Имя параметра: bytes</em></p>]]></content>
			<author>
				<name><![CDATA[Dmitriy]]></name>
				<uri>https://forum.guardant.ru/user/26/</uri>
			</author>
			<updated>2011-05-18T11:19:47Z</updated>
			<id>https://forum.guardant.ru/post/139/#p139</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/135/#p135" />
			<content type="html"><![CDATA[<p>Нет, Дмитрий, Вы не правы.</p><p>Строка &quot;11111111&quot; в unicode выглядит как 0x31 0x00 0x31 0x00 0x31 0x00 ....</p><p>См. <a href="http://www.tamasoft.co.jp/en/general-info/unicode.html">таблицу символов unicode</a>.</p>]]></content>
			<author>
				<name><![CDATA[Алексей Перепелов]]></name>
				<uri>https://forum.guardant.ru/user/6/</uri>
			</author>
			<updated>2011-05-18T10:37:02Z</updated>
			<id>https://forum.guardant.ru/post/135/#p135</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/133/#p133" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Алексей Перепелов пишет:</cite><blockquote><p>.......unicode-строкой (или, для очевидности, &quot;1\01\01\01\0&quot;)</p></blockquote></div><p>&quot;11111111&quot; в юникоде &quot;4949494949494949&quot;, как Вы получили из &quot;11111111&quot;-&gt; &quot;1\01\01\01\0&quot; ?</p>]]></content>
			<author>
				<name><![CDATA[Dmitriy]]></name>
				<uri>https://forum.guardant.ru/user/26/</uri>
			</author>
			<updated>2011-05-18T10:27:13Z</updated>
			<id>https://forum.guardant.ru/post/133/#p133</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/129/#p129" />
			<content type="html"><![CDATA[<p>Судя по всему, решение найдено.</p><p>Дело в том, что в Embarcadero RAD Studio строки кодируются в unicode. Соответственно, в нашем случае, для корректного расшифрования в C# вектор &quot;11111111&quot; должен быть представлен unicode-строкой (или, для очевидности, &quot;1\01\01\01\0&quot;)</p><p>Попробуйте так:<br /></p><div class="codebox"><pre><code>            Int64 initVectorGS2 = FromStringToInt64(&quot;1\01\01\01\0&quot;);
            RetCode = GrdApi.GrdCrypt(GrdHandle,
                                               GrdAN.GSII64,
                                               bArr,
                                               (UInt32)GrdAM.OFB + (UInt32)GrdAM.Decode,
                                               initVectorGS2);</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Алексей Перепелов]]></name>
				<uri>https://forum.guardant.ru/user/6/</uri>
			</author>
			<updated>2011-05-18T09:27:39Z</updated>
			<id>https://forum.guardant.ru/post/129/#p129</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/125/#p125" />
			<content type="html"><![CDATA[<p>Письмо получил. Завтра задам вопрос коллегам. Может чего и придумаем.</p>]]></content>
			<author>
				<name><![CDATA[Алексей Перепелов]]></name>
				<uri>https://forum.guardant.ru/user/6/</uri>
			</author>
			<updated>2011-05-17T16:17:53Z</updated>
			<id>https://forum.guardant.ru/post/125/#p125</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/124/#p124" />
			<content type="html"><![CDATA[<p>Не ясная ситуация конечно, можно ли как-то поставить эту проблему на повестку дня, официально получить ответ от Guardant, как можно решит данный вопрос.<br /><strong>P.S.</strong>Более детально о нашем проекте я написал Вам в письме и отправил на hotline@guardant.ru с темой &quot;для Алексея Перепелова&quot;</p>]]></content>
			<author>
				<name><![CDATA[Dmitriy]]></name>
				<uri>https://forum.guardant.ru/user/26/</uri>
			</author>
			<updated>2011-05-17T16:06:07Z</updated>
			<id>https://forum.guardant.ru/post/124/#p124</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/123/#p123" />
			<content type="html"><![CDATA[<p>Дмитрий,</p><p>Предполагаю, что Вы используете Embarcadero RAD Studio 2010 (или что-то подобное).</p><p>Если так, то судя по всему, проблема в компиляторе&nbsp; (или настройках компилятора/отладчика). </p><p>Пробовал зашифровать &quot;test&quot; в C++, C# и Delphi 7 - получил 150 188 22 208 229 124 23 192<br />Тот же код шифрования &quot;test&quot; в RAD Studio 2010 выдает 246 58 75 196 231 189 225 186</p><p>Вряд ли я ошибся в коде, так как, в частности, в Rad-студии и Delphi 7 компилировался один и тот же исходник. Результаты разные.</p><p>Я как-то встречался уже раньше с подобным &quot;своеволием&quot; приложения, собранного в Rad-студии. Однако тогда не было времени разбираться. В результате пришлось компилировать все в Delphi 7.</p><p>Попробуйте Delphi 7. Если заработает - хорошо. И если вдруг поймете, что нужно Rad-студии для нормальной работы - буду рад, если поделитесь.</p>]]></content>
			<author>
				<name><![CDATA[Алексей Перепелов]]></name>
				<uri>https://forum.guardant.ru/user/6/</uri>
			</author>
			<updated>2011-05-17T15:30:26Z</updated>
			<id>https://forum.guardant.ru/post/123/#p123</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Строковый вектор инициализации]]></title>
			<link rel="alternate" href="https://forum.guardant.ru/post/122/#p122" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Dmitriy пишет:</cite><blockquote><div class="quotebox"><cite>romik пишет:</cite><blockquote><p>Объявляйте переменную, присваивайте ей символьное значение, и используйте эту переменную в качестве параметра GrdCrypt.</p></blockquote></div><p>Уважаемый Михаил,просьба <span class="bbu">внимательно прочитать</span> мой первый пост. Не думаю,что есть смысл на этом форуме писать ради того, чтобы писать, тут нет рейтингов и тому подобных статистических вещей. Этот форум -&nbsp; место, где можно обменяться опытом и обсудить вопросы.</p></blockquote></div><p>Извините что пытался помочь, отвечая на заданый мне вопрос &quot;как все же быть с корректной декодировкой строки с символьным вектором?&quot;. Больше не буду.</p>]]></content>
			<author>
				<name><![CDATA[romik]]></name>
				<uri>https://forum.guardant.ru/user/14/</uri>
			</author>
			<updated>2011-05-17T14:02:10Z</updated>
			<id>https://forum.guardant.ru/post/122/#p122</id>
		</entry>
</feed>
