Skip to content

Instantly share code, notes, and snippets.

@alejandrobernardis
Created April 23, 2014 07:38
Show Gist options
  • Save alejandrobernardis/11205806 to your computer and use it in GitHub Desktop.
Save alejandrobernardis/11205806 to your computer and use it in GitHub Desktop.
Password Generator
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2013 Asumi Kamikaze Inc.
# Copyright (c) 2013 The Octopus Apps Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
# Author: Alejandro M. Bernardis
# Email: alejandro.bernardis at gmail.com
# Created: 02/Dec/2013 16:48
import datetime
import hashlib
import string
from random import choice
def secret_key(length=64):
h = '%s|%s|%s|%s' % (
datetime.datetime.utcnow().strftime('%Y%m%d%H%M%S%f'),
string.ascii_letters, string.digits, '~!@#$%^&*+')
return ''.join([choice(h) for _ in range(length)])
p = secret_key(8)
ph = hashlib.sha1()
ph.update(p)
title = 'Password Creator:'
print
print title
print '-'*len(title)
print 'Password:', p
print 'SHA1:', ph.hexdigest()
print
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2013 Asumi Kamikaze Inc.
# Copyright (c) 2013 The Octopus Apps Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
# Author: Alejandro M. Bernardis
# Email: alejandro.bernardis at gmail.com
# Created: 02/Dec/2013 16:48
import datetime
import hashlib
import string
from random import choice
def secret_key(length=64):
h = '%s|%s|%s|%s' % (
datetime.datetime.utcnow().strftime('%Y%m%d%H%M%S%f'),
string.ascii_letters, string.digits, string.punctuation)
return ''.join([choice(h) for _ in range(length)])
p = secret_key()
ph = hashlib.sha1()
ph.update(p)
title = 'Password Creator:'
print
print title
print '-'*len(title)
print 'Password:', p
print 'SHA1:', ph.hexdigest()
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment