<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Текст в Base64]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=10561</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=10561&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Текст в Base64».]]></description>
		<lastBuildDate>Tue, 09 Aug 2022 21:07:05 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154290#p154290</link>
			<description><![CDATA[<p><strong>teadrinker</strong><br />Вроде сработало, спасибо. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (Gh0sTG0)]]></author>
			<pubDate>Tue, 09 Aug 2022 21:07:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154290#p154290</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154289#p154289</link>
			<description><![CDATA[<p>Замените BASE642String() на<br /></p><div class="codebox"><pre><code>BASE642String(StringBASE64)
{
   size := StringBase64ToData(StringBase64, Data)
   Return StrGet(&amp;Data, size &gt;&gt; !!A_IsUnicode, A_IsUnicode ? &quot;UTF-16&quot; : &quot;cp0&quot;)
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 09 Aug 2022 21:04:07 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154289#p154289</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154288#p154288</link>
			<description><![CDATA[<p><strong>teadrinker</strong><br />Добрый вечер.<br /><em>К посту от 2015-04-07 23:15:47.</em><br />Напишу тут, мб кто увидит этот некро, хех <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />.<br />Как его обнулять чтобы использовать больше 1 раза?<br />Проверил все свои переменные, все пообнулял, остались только твои функции.<br />Собственно, в чем проблема:<br />Есть, к примеру, 2 фразы: &quot;папа любит маму&quot; и &quot;сын ест&quot;. Закодированны путем скидывания в String2BASE64.<br />2 объекта для раскодировки, раскодировка происходит в 2 приема.<br />Loop<br />{<br />	1 проход: раскодировщик раскодирует и выдает &quot;папа любит маму&quot; -&gt; &quot;<em>папа лю</em><strong>бит маму</strong>&quot;.<br />	2 проход: раскодировщик раскодирует и выдает &quot;сын ест&quot; -&gt; &quot;<em>сын ест</em><strong>бит маму</strong>&quot;.<br />}<br />То есть, где то, что то не обнулилось. При том очень странно не обнулилось...<br />Если я добавлю 3ю фразу &quot;<span class="bbu">Соба</span>&quot;, 3 проход выдаст: &quot;<span class="bbu">Соба</span><em>ест</em><strong>бит маму</strong>&quot;.<br />Если я сделаю &quot;Reload&quot; между раскодировками, то оно раскодирует корректно, но мне придется запускать каждый проход вручную, вместо запуска &quot;всех&quot; проходов разом.<br />Не очень понимаю что там настолько экзотически перезаполняется, но очень хотелось бы узнать где это что то обнулять.<br />Вроде с кодированием такой проблемы не было, но это не точно.</p>]]></description>
			<author><![CDATA[null@example.com (Gh0sTG0)]]></author>
			<pubDate>Tue, 09 Aug 2022 19:49:20 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154288#p154288</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=93101#p93101</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>заменять переносы строк какими-либо редко встречающимися символами</p></blockquote></div><p>Так нет гарантий, мало ли что за текст.<br /></p><div class="quotebox"><blockquote><p>Без переносов так нужно:</p></blockquote></div><p>Я CRYPT_STRING_NOCRLF сразу заметил, спасибо, до этого сам переносы удалял.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 07 Apr 2015 20:19:26 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=93101#p93101</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=93100#p93100</link>
			<description><![CDATA[<p>Кстати, по умолчанию ф-ция <em>CryptBinaryToString</em> сама переносы строк добавляет после определённого количества символов. Без переносов так нужно:<br /></p><div class="codebox"><pre><code>string =
(
однажды вычеркнув из жизни
всё то что делал не любя
ты неожиданно встречаешь
себя
)

MsgBox, % StringBASE64 := String2BASE64(string, 1)
MsgBox, % BASE642String(StringBASE64)

String2BASE64(str, NOCRLF)
{
   Return CryptBinaryToStringBASE64(&amp;str, StrLen(str) * (A_IsUnicode ? 2 : 1), NOCRLF)
}

BASE642String(StringBASE64)
{
   size := StringBase64ToData(StringBase64, Data)
   Return StrGet(&amp;Data, size &gt;&gt; !!A_IsUnicode, A_IsUnicode ? &quot;UTF-16&quot; : &quot;cp0&quot;)
}
   
CryptBinaryToStringBASE64(pData, Bytes, NOCRLF = &quot;&quot;)
{
   static CRYPT_STRING_BASE64 := 1, CRYPT_STRING_NOCRLF := 0x40000000
   Crypt := CRYPT_STRING_BASE64 | (NOCRLF ? CRYPT_STRING_NOCRLF : 0)
   
   DllCall(&quot;Crypt32.dll\CryptBinaryToString&quot;, Ptr, pData, UInt, Bytes, UInt, Crypt, Ptr, 0, UIntP, Chars)
   VarSetCapacity(OutData, Chars * (A_IsUnicode ? 2 : 1))
   DllCall(&quot;Crypt32.dll\CryptBinaryToString&quot;, Ptr, pData, UInt, Bytes, UInt, Crypt, Str, OutData, UIntP, Chars)
   Return OutData
}

StringBase64ToData(StringBase64, ByRef OutData)
{
   static CRYPT := CRYPT_STRING_BASE64 := 1
   
   DllCall(&quot;Crypt32.dll\CryptStringToBinary&quot;, Ptr, &amp;StringBase64
      , UInt, StrLen(StringBase64), UInt, CRYPT, UInt, 0, UIntP, Bytes, UIntP, 0, UIntP, 0)
   VarSetCapacity(OutData, Bytes) 
   DllCall(&quot;Crypt32.dll\CryptStringToBinary&quot;, Ptr, &amp;StringBase64
      , UInt, StrLen(StringBase64), UInt, CRYPT, Str, OutData, UIntP, Bytes, UIntP, 0, UIntP, 0)
   Return Bytes
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 07 Apr 2015 20:15:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=93100#p93100</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=93099#p93099</link>
			<description><![CDATA[<p>Если речь о переносе строк в ini-файле идёт, тогда понятно. В буфере обмена по тем же причинам ini избегал. Хотя, в принципе, можно просто заменять переносы строк какими-либо редко встречающимися символами, которых наверняка не будет в тексте.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 07 Apr 2015 20:14:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=93099#p93099</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=93098#p93098</link>
			<description><![CDATA[<p>Кирилица не причём. Ну к примеру надо сохранить в ини файл текст, а в нём есть перенос строки и что то в тексте совпадёт со структурой INI.<br /></p><div class="codebox"><pre><code>Ini = %A_ScriptDir%\INI-File.ini   
Key1 = aaa`nKey2=bbb
Key2 = ccc
IniWrite, %Key2%, %Ini%, Section, Key2
IniWrite, %Key1%, %Ini%, Section, Key1 
IniDelete, %Ini%, Section, Key2
IniRead, Data, %Ini%, Section, Key1
MsgBox % Data
IniRead, Data, %Ini%, Section, Key2
MsgBox % Data</code></pre></div><p>А Ты сам, зачем в менеджере буфера обмена заморачивался?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 07 Apr 2015 20:05:29 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=93098#p93098</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=93097#p93097</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>как сохранять в файл куски текста</p></blockquote></div><p>А какая разница, в каком виде сохранять? И тут, и там строка получается. Или это чтобы избежать кириллицы?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 07 Apr 2015 19:50:42 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=93097#p93097</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=93095#p93095</link>
			<description><![CDATA[<p>Да возник вопрос, как сохранять в файл куски текста, чтобы его потом можно было легко разобрать, ну а для дилетанта это самый простой путь. Хотя такую же реализацию наблюдал много где, в основном вставляют в XML строки Base64.<br />Видел как у тебя в недавнем менеджере буфера обмена лихо закручено, но это не для средних умов. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 07 Apr 2015 19:40:38 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=93095#p93095</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=93094#p93094</link>
			<description><![CDATA[<p>Только зачем строку кодировать? По объёму больше получается.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 07 Apr 2015 19:17:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=93094#p93094</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=93093#p93093</link>
			<description><![CDATA[<p>Переменная с текстом и так уже есть в бинарном виде в памяти, ничего переводить не нужно.<br /></p><div class="codebox"><pre><code>string =
(
однажды вычеркнув из жизни
всё то что делал не любя
ты неожиданно встречаешь
себя
)

MsgBox, % StringBASE64 := String2BASE64(string)
MsgBox, % BASE642String(StringBASE64)

String2BASE64(str)
{
   Return CryptBinaryToStringBASE64(&amp;str, StrLen(str) * (A_IsUnicode ? 2 : 1))
}

BASE642String(StringBASE64)
{
   StringBase64ToData(StringBase64, Data)
   Return Data
}
   
CryptBinaryToStringBASE64(pData, Bytes, NOCRLF = &quot;&quot;)
{
   static CRYPT_STRING_BASE64 := 1, CRYPT_STRING_NOCRLF := 0x40000000
   Crypt := CRYPT_STRING_BASE64 | (NOCRLF ? CRYPT_STRING_NOCRLF : 0)
   
   DllCall(&quot;Crypt32.dll\CryptBinaryToString&quot;, Ptr, pData, UInt, Bytes, UInt, Crypt, Ptr, 0, UIntP, Chars)
   VarSetCapacity(OutData, Chars * (A_IsUnicode ? 2 : 1))
   DllCall(&quot;Crypt32.dll\CryptBinaryToString&quot;, Ptr, pData, UInt, Bytes, UInt, Crypt, Str, OutData, UIntP, Chars)
   Return OutData
}

StringBase64ToData(StringBase64, ByRef OutData)
{
   static CRYPT := CRYPT_STRING_BASE64 := 1
   
   DllCall(&quot;Crypt32.dll\CryptStringToBinary&quot;, Ptr, &amp;StringBase64
      , UInt, StrLen(StringBase64), UInt, CRYPT, UInt, 0, UIntP, Bytes, UIntP, 0, UIntP, 0)
   VarSetCapacity(OutData, Bytes) 
   DllCall(&quot;Crypt32.dll\CryptStringToBinary&quot;, Ptr, &amp;StringBase64
      , UInt, StrLen(StringBase64), UInt, CRYPT, Str, OutData, UIntP, Bytes, UIntP, 0, UIntP, 0)
   Return Bytes
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 07 Apr 2015 19:11:29 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=93093#p93093</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=93092#p93092</link>
			<description><![CDATA[<p>Пробую закодировать, ничего.<br /></p><div class="codebox"><pre><code>
Str = Серый форум
StrPutVar(Str, Bin, &quot;UTF-16&quot;)
MsgBox % BinToBase64(Bin)

BinToBase64(Bin) {   
    DllCall(&quot;Crypt32.dll\CryptBinaryToString&quot; (A_IsUnicode ? &quot;W&quot; : &quot;A&quot;) 
        , UInt,&amp;Bin, UInt,Size, UInt,1, UInt,0, UIntP,TChars, &quot;CDECL Int&quot;) 
    VarSetCapacity(Base64, Req := TChars * (A_IsUnicode ? 2 : 1)) 
    DllCall(&quot;Crypt32.dll\CryptBinaryToString&quot; (A_IsUnicode ? &quot;W&quot; : &quot;A&quot;) 
        , UInt,&amp;Bin, UInt,Size, UInt,1, Str,Base64, UIntP,Req, &quot;CDECL Int&quot;) 
    Return Base64
}

StrPutVar(string, ByRef var, encoding)
{
    ; Ensure capacity.
    VarSetCapacity( var, StrPut(string, encoding)
        ; StrPut returns char count, but VarSetCapacity needs bytes.
        * ((encoding=&quot;utf-16&quot;||encoding=&quot;cp1200&quot;) ? 2 : 1) )
    ; Copy or convert the string.
    return StrPut(string, &amp;var, encoding)
}
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 07 Apr 2015 19:11:19 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=93092#p93092</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Текст в Base64]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=93091#p93091</link>
			<description><![CDATA[<p>Не нашёл способа преобразования текста (переменной с текстом) в Base64 и обратно, без создания файла. <br />Так понимаю, что нужно как-то&quot;перевести&quot; переменную с текстом в бинарный вид, а при декодировании прочитать как UTF-16?</p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>
Base64ToBin(Base64) {    
    DllCall(&quot;Crypt32.dll\CryptStringToBinary&quot; (A_IsUnicode ? &quot;W&quot; : &quot;A&quot;), UInt,&amp;Base64 
        , UInt,StrLen(Base64), UInt,1, UInt,0, UIntP,Bytes, Int,0, Int,0, &quot;CDECL Int&quot;) 
    VarSetCapacity(Bin, Req := Bytes * (A_IsUnicode ? 2 : 1)) 
    DllCall(&quot;Crypt32.dll\CryptStringToBinary&quot; (A_IsUnicode ? &quot;W&quot; : &quot;A&quot;), UInt,&amp;Base64 
        , UInt,StrLen(Base64), UInt,1, Str,Bin, UIntP,Req, Int,0, Int,0, &quot;CDECL Int&quot;)    
    Return Bin
}  
 
BinToBase64(Bin) {   
    DllCall(&quot;Crypt32.dll\CryptBinaryToString&quot; (A_IsUnicode ? &quot;W&quot; : &quot;A&quot;) 
        , UInt,&amp;Bin, UInt,Size, UInt,1, UInt,0, UIntP,TChars, &quot;CDECL Int&quot;) 
    VarSetCapacity(Base64, Req := TChars * (A_IsUnicode ? 2 : 1)) 
    DllCall(&quot;Crypt32.dll\CryptBinaryToString&quot; (A_IsUnicode ? &quot;W&quot; : &quot;A&quot;) 
        , UInt,&amp;Bin, UInt,Size, UInt,1, Str,Base64, UIntP,Req, &quot;CDECL Int&quot;) 
    Return Base64
}
</code></pre></div></div></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 07 Apr 2015 18:43:28 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=93091#p93091</guid>
		</item>
	</channel>
</rss>
