Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

C#

Get MD5 Hash

1
2
3
4
5
6
7
public static string GetHash(string str)
{
    using (var md5 = MD5.Create())
    {
        return BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(str))).Replace("-", "").ToLower();
    }
}
https://snipt.net/embed/d0fb91df388e6d9e725fe69d6e1278aa/
https://snipt.net/raw/d0fb91df388e6d9e725fe69d6e1278aa/
d0fb91df388e6d9e725fe69d6e1278aa
csharp
C#
7
2016-12-07T22:46:44
True
False
False
Apr 07, 2016 at 01:06 PM
/api/public/snipt/145244/
get-md5-hash
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">public</span> <span class="k">static</span> <span class="kt">string</span> <span class="nf">GetHash</span><span class="p">(</span><span class="kt">string</span> <span class="n">str</span><span class="p">)</span> </span><span id="L-2"><a name="L-2"></a><span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">using</span> <span class="p">(</span><span class="kt">var</span> <span class="n">md5</span> <span class="p">=</span> <span class="n">MD5</span><span class="p">.</span><span class="n">Create</span><span class="p">())</span> </span><span id="L-4"><a name="L-4"></a> <span class="p">{</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">return</span> <span class="n">BitConverter</span><span class="p">.</span><span class="n">ToString</span><span class="p">(</span><span class="n">md5</span><span class="p">.</span><span class="n">ComputeHash</span><span class="p">(</span><span class="n">Encoding</span><span class="p">.</span><span class="n">UTF8</span><span class="p">.</span><span class="n">GetBytes</span><span class="p">(</span><span class="n">str</span><span class="p">))).</span><span class="n">Replace</span><span class="p">(</span><span class="s">&quot;-&quot;</span><span class="p">,</span> <span class="s">&quot;&quot;</span><span class="p">).</span><span class="n">ToLower</span><span class="p">();</span> </span><span id="L-6"><a name="L-6"></a> <span class="p">}</span> </span><span id="L-7"><a name="L-7"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
hash, md5

Bash

get file MD5

file="/path/to/some/file"
md5=$(md5sum "$file" 2>/dev/null | awk '{print $1}')
https://snipt.net/embed/7502b80883172beaabff83951c07909a/
https://snipt.net/raw/7502b80883172beaabff83951c07909a/
7502b80883172beaabff83951c07909a
bash
Bash
2
2016-12-05T17:07:19
True
False
False
Oct 01, 2015 at 05:07 AM
/api/public/snipt/141374/
get-file-md5
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nv">file</span><span class="o">=</span><span class="s2">&quot;/path/to/some/file&quot;</span> </span><span id="L-2"><a name="L-2"></a><span class="nv">md5</span><span class="o">=</span><span class="k">$(</span>md5sum <span class="s2">&quot;</span><span class="nv">$file</span><span class="s2">&quot;</span> 2&gt;/dev/null <span class="p">|</span> awk <span class="s1">&#39;{print $1}&#39;</span><span class="k">)</span> </span></pre></div> </td></tr></table>
hash, linux, md5

Text only

Calculate MD5 off a string

from mac terminal:
md5 -q -s mypassword
https://snipt.net/embed/8d2cdaa4f0adaf7708045c2c4fb54674/
https://snipt.net/raw/8d2cdaa4f0adaf7708045c2c4fb54674/
8d2cdaa4f0adaf7708045c2c4fb54674
text
Text only
2
2016-12-07T22:44:34
True
False
False
Dec 14, 2012 at 10:44 AM
/api/public/snipt/51852/
calculate-md5-off-a-string
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>from mac terminal: </span><span id="L-2"><a name="L-2"></a>md5 -q -s mypassword </span></pre></div> </td></tr></table>
mac, md5

PHP

random md5

md5(uniqid(rand(), true));
https://snipt.net/embed/518bd8b47f86b6da19882ab64a97b066/
https://snipt.net/raw/518bd8b47f86b6da19882ab64a97b066/
518bd8b47f86b6da19882ab64a97b066
php
PHP
1
2016-12-07T21:31:32
True
False
False
/api/public/snipt/12044/
random-md5
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">md5(uniqid(rand(), true));</span> </span></pre></div> </td></tr></table>
md5, php, random

MySQL

MD5 MySQL

insert into usuarios(usuario,nombres,apellidos,passwd) values('bond','James','Bond',md5('administrador'));
https://snipt.net/embed/b926eb66dbba9f6af6a786408b7c6e3b/
https://snipt.net/raw/b926eb66dbba9f6af6a786408b7c6e3b/
b926eb66dbba9f6af6a786408b7c6e3b
mysql
MySQL
1
2016-12-07T22:45:47
True
False
False
/api/public/snipt/4873/
md5-mysql
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">insert</span> <span class="k">into</span> <span class="nf">usuarios</span><span class="p">(</span><span class="n">usuario</span><span class="p">,</span><span class="n">nombres</span><span class="p">,</span><span class="n">apellidos</span><span class="p">,</span><span class="n">passwd</span><span class="p">)</span> <span class="k">values</span><span class="p">(</span><span class="s1">&#39;bond&#39;</span><span class="p">,</span><span class="s1">&#39;James&#39;</span><span class="p">,</span><span class="s1">&#39;Bond&#39;</span><span class="p">,</span><span class="nf">md5</span><span class="p">(</span><span class="s1">&#39;administrador&#39;</span><span class="p">));</span> </span></pre></div> </td></tr></table>
md5, mysql
Copyrighted, illegal, or inappropriate content? Email [email protected].