<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBA: Перевод функции шифрования с Pascal на VBA]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=7831&amp;type=atom" />
	<updated>2012-11-30T22:04:40Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=7831</id>
		<entry>
			<title type="html"><![CDATA[Re: VBA: Перевод функции шифрования с Pascal на VBA]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=66317#p66317" />
			<content type="html"><![CDATA[<p>Честно говоря, я не силён в VB, а точнее, вообще с ним почти не знаком, могу помочь только тем, что помню из курса Паскаля.<br />^ в паскале - указатель (разыменование)<br /></p><div class="codebox"><pre><code>Somevar := 5; // допустим это переменная типа integer, теперь она = 5
A := @Somevar; // теперь A содержит указатель (ссылку) на SomeVar
A^ := 6; // теперь Somevar == 6, мы изменили значение переменной, расположенной по адресу A.</code></pre></div><p>Хотя, честно говоря, я в этом не уверен, поскольку Паскаль уже забывается по-тихоньку.</p><p>Знак доллара - это hex value, <strong>$FF</strong> (Паскаль) == <strong>255</strong> == 0xFF (С\JS) == <strong>&amp;HFF</strong> (а может, <strong>&amp;HFF&amp;</strong>, НЕ ЗНАЮ ТОЧНО, в VB).</p>]]></content>
			<author>
				<name><![CDATA[vo1ty]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28909</uri>
			</author>
			<updated>2012-11-30T22:04:40Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=66317#p66317</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBA: Перевод функции шифрования с Pascal на VBA]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=66316#p66316" />
			<content type="html"><![CDATA[<p>Уважаемые форумчане! Если не затруднит, помогите перевести с pascal на vba функцию шифрования<br /></p><div class="codebox"><pre><code>function Encryption(const Key: string; BufferIn, BufferOut: PByteArray; ReadOrWrite, Size: Integer): Integer;
var
   i: integer;
   k: integer;
begin
   Result := 0;
   if (Length(Key) = 0) then
   begin
      if BufferIn &lt;&gt; BufferOut then
         Move(BufferIn^,BufferOut^,Size);
      exit;
   end;
   if ReadOrWrite = 0 then  {Read operation, so decrypt}
   begin
      k := 1;
      for i := 0 to Size-1 do
      begin
         BufferOut^[i] := BufferIn^[i] xor (byte(Key[k]) or (i and $FF));
         inc(k);
         if k &gt; length(Key) then k := 1;
      end;
      Result := -1;   {Decrypted}
   end
   else
   begin                    {write operation, so encrypt}
      k := 1;
      for i := 0 to Size-1 do
      begin
         BufferOut^[i] := BufferIn^[i] xor (byte(Key[k]) or (i and $FF));
         inc(k);
         if k &gt; length(Key) then k := 1;
      end;
      Result := 1;       {Encrypted}
   end;
end;

end.</code></pre></div><p>Особые затруднения вызывают ^ и $FF</p>]]></content>
			<author>
				<name><![CDATA[Dim]]></name>
			</author>
			<updated>2012-11-30T18:31:31Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=66316#p66316</id>
		</entry>
</feed>
