Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Ruby

enconde decode files base 64

1
2
3
4
# Encode a file to base64 encoding:
File.open("output_file","w"){|file| file.write [open("link_to_file").string].pack("m")}
# Decode base64 encoded file:
File.open('original', 'wb') {|file| file << (IO.readlines('output_file').to_s.unpack('m')).first }
https://snipt.net/embed/22b6ac31610283e24631a1a68410560b/
https://snipt.net/raw/22b6ac31610283e24631a1a68410560b/
22b6ac31610283e24631a1a68410560b
rb
Ruby
5
2016-12-07T19:32:32
True
False
False
/api/public/snipt/14326/
enconde-decode-files-base-64
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># Encode a file to base64 encoding:</span> </span><span id="L-2"><a name="L-2"></a><span class="no">File</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s2">&quot;output_file&quot;</span><span class="p">,</span><span class="s2">&quot;w&quot;</span><span class="p">){</span><span class="o">|</span><span class="n">file</span><span class="o">|</span> <span class="n">file</span><span class="o">.</span><span class="n">write</span> <span class="o">[</span><span class="nb">open</span><span class="p">(</span><span class="s2">&quot;link_to_file&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">string</span><span class="o">].</span><span class="n">pack</span><span class="p">(</span><span class="s2">&quot;m&quot;</span><span class="p">)}</span> </span><span id="L-3"><a name="L-3"></a><span class="c1"># Decode base64 encoded file:</span> </span><span id="L-4"><a name="L-4"></a><span class="no">File</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;original&#39;</span><span class="p">,</span> <span class="s1">&#39;wb&#39;</span><span class="p">)</span> <span class="p">{</span><span class="o">|</span><span class="n">file</span><span class="o">|</span> <span class="n">file</span> <span class="o">&lt;&lt;</span> <span class="p">(</span><span class="no">IO</span><span class="o">.</span><span class="n">readlines</span><span class="p">(</span><span class="s1">&#39;output_file&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">to_s</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="s1">&#39;m&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">first</span> <span class="p">}</span> </span></pre></div> </td></tr></table>
base64, ruby

Python

decoding those nasty base64 hacks to see what's running

python -c "import base64;print base64.decodestring('aHR0cDovL3NwYW1zaXRlLmNvbQ==')"
https://snipt.net/embed/2ce6bc60f33d933ab82dd43160798dbc/
https://snipt.net/raw/2ce6bc60f33d933ab82dd43160798dbc/
2ce6bc60f33d933ab82dd43160798dbc
python
Python
1
2016-12-02T18:34:31
True
False
False
/api/public/snipt/9663/
decoding-those-nasty-base64-hacks-to-see-whats-running
<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="n">python</span> <span class="o">-</span><span class="n">c</span> <span class="s2">&quot;import base64;print base64.decodestring(&#39;aHR0cDovL3NwYW1zaXRlLmNvbQ==&#39;)&quot;</span> </span></pre></div> </td></tr></table>
64, base, base64, decode, python

PHP

get data:image

<img alt=”logo” src=”data:image/gif;base64,<?php echo base64_encode(file_get_contents("logo.gif")) ?>”>
https://snipt.net/embed/19a4b371f306c839d83f1608176a0a63/
https://snipt.net/raw/19a4b371f306c839d83f1608176a0a63/
19a4b371f306c839d83f1608176a0a63
php
PHP
1
2016-11-06T14:17:43
True
False
False
/api/public/snipt/8648/
get-dateimage
<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">&lt;img alt=”logo” src=”data:image/gif;base64,</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nb">base64_encode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s2">&quot;logo.gif&quot;</span><span class="p">))</span> <span class="cp">?&gt;</span><span class="x">”&gt;</span> </span></pre></div> </td></tr></table>
base64, php
Copyrighted, illegal, or inappropriate content? Email [email protected].