<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[CryptoPP] SHA1-Hash von wstring erstellen]]></title><description><![CDATA[<p>Hi,</p>
<p>ich möchte mit CryptoPP einen SHA1-Hash eines std::wstring erzeugen.<br />
Leider kommt bei meinem Code nicht das gleiche raus, wie bei einem SHA1-Encoder im Internet.<br />
Was mache ich falsch?</p>
<pre><code class="language-cpp">std::wstring input = L&quot;Hallo Welt&quot;;

    byte buffer[CryptoPP::SHA1::DIGESTSIZE];

    const byte* inp = reinterpret_cast&lt;const byte*&gt;(input.c_str());

    CryptoPP::SHA1().CalculateDigest(buffer,inp,sizeof(inp));

    std::string hash;
    CryptoPP::StringSource ss(buffer, sizeof(buffer), true,
    new CryptoPP::HexEncoder(
        new CryptoPP::StringSink(hash)
    )
    );
</code></pre>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/305648/cryptopp-sha1-hash-von-wstring-erstellen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 08 Aug 2026 19:59:21 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/305648.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Jul 2012 10:16:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [CryptoPP] SHA1-Hash von wstring erstellen on Wed, 04 Jul 2012 10:16:01 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich möchte mit CryptoPP einen SHA1-Hash eines std::wstring erzeugen.<br />
Leider kommt bei meinem Code nicht das gleiche raus, wie bei einem SHA1-Encoder im Internet.<br />
Was mache ich falsch?</p>
<pre><code class="language-cpp">std::wstring input = L&quot;Hallo Welt&quot;;

    byte buffer[CryptoPP::SHA1::DIGESTSIZE];

    const byte* inp = reinterpret_cast&lt;const byte*&gt;(input.c_str());

    CryptoPP::SHA1().CalculateDigest(buffer,inp,sizeof(inp));

    std::string hash;
    CryptoPP::StringSource ss(buffer, sizeof(buffer), true,
    new CryptoPP::HexEncoder(
        new CryptoPP::StringSink(hash)
    )
    );
</code></pre>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2229951</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2229951</guid><dc:creator><![CDATA[Raven280438]]></dc:creator><pubDate>Wed, 04 Jul 2012 10:16:01 GMT</pubDate></item><item><title><![CDATA[Reply to [CryptoPP] SHA1-Hash von wstring erstellen on Wed, 04 Jul 2012 10:22:09 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">sizeof(inp)
</code></pre>
<p>wird 4 oder 8 sein, die Größe eines Zeigers auf deinem System. Nicht mit C-Strings fummeln, wenn man es nicht kann. Warum der Umweg?</p>
<p>Ungetestet:</p>
<pre><code class="language-cpp">std::string input = &quot;Hallo Welt&quot;;  // Willst du hier wirklich wstring?
    CryptoPP::SHA1().CalculateDigest(buffer,input.data(),input.length());
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2229954</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2229954</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 04 Jul 2012 10:22:09 GMT</pubDate></item><item><title><![CDATA[Reply to [CryptoPP] SHA1-Hash von wstring erstellen on Wed, 04 Jul 2012 10:23:52 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>der Input ist ein vom User eingegebenes Passwort. Das kann natürlich Sonderzeichen und Umlaute enthalten.<br />
Da muss man doch wstring nehmen, oder hab ich da was falsch verstanden?</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2229956</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2229956</guid><dc:creator><![CDATA[Raven280438]]></dc:creator><pubDate>Wed, 04 Jul 2012 10:23:52 GMT</pubDate></item><item><title><![CDATA[Reply to [CryptoPP] SHA1-Hash von wstring erstellen on Wed, 04 Jul 2012 10:24:00 GMT]]></title><description><![CDATA[<p><code>sizeof( inp )</code> liefert dir die Größe des Zeigers, nicht die Länge der Eingabedaten. Du suchst die Länge des <code>wstrings</code> in Bytes.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2229957</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2229957</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Wed, 04 Jul 2012 10:24:00 GMT</pubDate></item><item><title><![CDATA[Reply to [CryptoPP] SHA1-Hash von wstring erstellen on Wed, 04 Jul 2012 10:54:16 GMT]]></title><description><![CDATA[<p>Raven280438 schrieb:</p>
<blockquote>
<p>Hi,</p>
<p>der Input ist ein vom User eingegebenes Passwort. Das kann natürlich Sonderzeichen und Umlaute enthalten.<br />
Da muss man doch wstring nehmen, oder hab ich da was falsch verstanden?</p>
<p>Gruß</p>
</blockquote>
<p>Nö. Per UTF-8 lassen sich Umlaute auch in 8bit chars codieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2229967</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2229967</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Wed, 04 Jul 2012 10:54:16 GMT</pubDate></item><item><title><![CDATA[Reply to [CryptoPP] SHA1-Hash von wstring erstellen on Wed, 04 Jul 2012 10:58:54 GMT]]></title><description><![CDATA[<p>Ethon schrieb:</p>
<blockquote>
<p>Nö. Per UTF-8 lassen sich Umlaute auch in 8bit chars codieren.</p>
</blockquote>
<p>Ok, und wie muss ich vorgehen, um das Projekt auf UTF8 umzustellen?<br />
(ich arbeite mit Code::Blocks)</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2229969</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2229969</guid><dc:creator><![CDATA[Raven280438]]></dc:creator><pubDate>Wed, 04 Jul 2012 10:58:54 GMT</pubDate></item><item><title><![CDATA[Reply to [CryptoPP] SHA1-Hash von wstring erstellen on Wed, 04 Jul 2012 12:16:54 GMT]]></title><description><![CDATA[<p>Reicht es schon, wenn ich in den Editor-Optionen das Datei-Encoding auf UTF8 stelle?<br />
Eine andere Einstellung hab ich nicht gefunden...</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2230005</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2230005</guid><dc:creator><![CDATA[Raven280438]]></dc:creator><pubDate>Wed, 04 Jul 2012 12:16:54 GMT</pubDate></item><item><title><![CDATA[Reply to [CryptoPP] SHA1-Hash von wstring erstellen on Wed, 04 Jul 2012 15:01:16 GMT]]></title><description><![CDATA[<p>Im Endeffekt ist es ein Implementierungsdetail, aber du kannst zu 99% davon ausgehen, dass normale char Strings UTF-8 sind.</p>
<pre><code class="language-cpp">char const* str = &quot;äöü&quot;;
assert(std::strlen(str) == 6);
</code></pre>
<p>Denn ein Umlaut benötigt UTF-8 codiert 2 Bytes. DEswegen lässt es sich auch nicht vernünftig per printf/cout ausgeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2230055</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2230055</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Wed, 04 Jul 2012 15:01:16 GMT</pubDate></item><item><title><![CDATA[Reply to [CryptoPP] SHA1-Hash von wstring erstellen on Wed, 04 Jul 2012 15:41:48 GMT]]></title><description><![CDATA[<p>Ethon schrieb:</p>
<blockquote>
<p>Im Endeffekt ist es ein Implementierungsdetail, aber du kannst zu 99% davon ausgehen, dass normale char Strings UTF-8 sind.</p>
</blockquote>
<p>Ist denn der Windows Anteil schon auf unter 1% zurückgegangen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2230063</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2230063</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Wed, 04 Jul 2012 15:41:48 GMT</pubDate></item><item><title><![CDATA[Reply to [CryptoPP] SHA1-Hash von wstring erstellen on Wed, 04 Jul 2012 15:48:33 GMT]]></title><description><![CDATA[<p>Womit werden denn sonst Narrowstrings auf Windowskisten codiert?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2230070</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2230070</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Wed, 04 Jul 2012 15:48:33 GMT</pubDate></item><item><title><![CDATA[Reply to [CryptoPP] SHA1-Hash von wstring erstellen on Wed, 04 Jul 2012 16:01:08 GMT]]></title><description><![CDATA[<p>Ethon schrieb:</p>
<blockquote>
<p>Womit werden denn sonst Narrowstrings auf Windowskisten codiert?</p>
</blockquote>
<p><code>Windows-1252</code> bei mir.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2230076</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2230076</guid><dc:creator><![CDATA[Caligulaminus]]></dc:creator><pubDate>Wed, 04 Jul 2012 16:01:08 GMT</pubDate></item><item><title><![CDATA[Reply to [CryptoPP] SHA1-Hash von wstring erstellen on Wed, 04 Jul 2012 21:07:35 GMT]]></title><description><![CDATA[<p>Das was eingestellt ist, und per Default ist das auf vielen Maschinen CP 1252, aka. Windows-Variante-von-Latin-I.<br />
Bzw. eben die &quot;passende&quot; Windows Codepage für die Locale die beim Installieren eingestellt wurde.</p>
<p>Man kann es soweit ich weiss manuell auf UTF-8 umstellen, nur meine ich mich zu erinnern dass es da diverse Warnungen gab, weil damit viele Programme Probleme haben, u.U. sogar welche die mit Windows mit installiert werden.</p>
<p>Auf jeden Fall kann man sich als Programm nicht darauf verlassen dass UTF-8 eingestellt ist, weil es einfach quasi niemand eingestellt hat. Daher arbeiten unter Windows auch &quot;alle&quot; mit UTF-16 Strings, weil die von den ganzen OS Funktionen &quot;native&quot; unterstützt werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2230144</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2230144</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Wed, 04 Jul 2012 21:07:35 GMT</pubDate></item></channel></rss>