Skip to content

Instantly share code, notes, and snippets.

View sandromello's full-sized avatar

Sandro Mello sandromello

View GitHub Profile
@sandromello
sandromello / Decode base64
Created September 25, 2012 16:43
Decode base64 string python
import base64
# Picture a scenario where you need to retrieve a base64 string and decrypt with a privatekey
base64str = 'E6ne2WavwjIBh3wmUtc1xQRhW9eSK4T5fNkP+GSpaUboKqiI0degfQ=='
decodedstr = base64.b64decode(base64str)
# Now you can decrypt it
decrypted = unpad(cipher.decrypt(decodestr))
@sandromello
sandromello / C implementation
Created September 21, 2012 22:31
MD5 and TripleDES - C# and Python implementation
using System.Security.Cryptography;
class Program
{
static void Main(string[] args)
{
var privatekey = "RN4nog0661VvjzphNg48372t747365mNfSxirueSDYstqsqeQn?=";
var skey = "e99308c2e3373fb041775a0c813f397d";
var c = new Program();
var encrypted = c.crypto(skey, privatekey, "encrypt");
bundle edit_line set_variable_values2(file,v)
#
# Another implementation of set_variable_values.
# The input and output should be exactly the same (except the file name),
# but in some Cfengine versions there are bugs,
# so this bundle can be used as a workaround.
#
{
vars:
@sandromello
sandromello / Run output
Created May 7, 2012 20:34 — forked from nickanderson/Run output
How to override bundle values with passed in paramaters
cf-agent -KIf ./paramaterized_bundle_override_defaults.cf
R: mycustomvalue <- this one was my value
R: ubuntuvalue2 <- I didnt override this one