nanak / pypass Goto Github PK
View Code? Open in Web Editor NEWSimple password generator
Simple password generator
Hab schnell mal einen transcoder für die unterschiedlichen Zahlensysteme geschrieben.
Der Vorteil ist das es damit sehr leicht möglich währe das der Benutzer selber festlegen kann wie das Passwort encoded werden soll, also welche Zeichen im Passwort vorkommen sollen.
BASE64_DIGITS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
BASE16_DIGITS = '0123456789ABCDEF'
BASE2_DIGITS = '01'
# Decodes an encoded number into a decimal number.
#
# data ... the encoded number (string)
# source ... the system the number is encoded in (string)
def decode(data, source):
value = 0
for d in data:
if d in source:
value = value * len(source)
value = value + source.find(d)
return value
# Encodes a decimal number into system given by target
#
# data ... number that should be encoded
# target ... system the number should be encoded to
def encode(data, target):
result = ''
while int(data) > 0:
r = int( data % len(target) )
result = target[r] + result
data = data / len(target)
return result
# Transcodes a number from one numeric system to another.
# For examples to see how a 'system' should look like, take a
# look at the constants BASE64_DIGITS, BASE16_DIGITS (hexadecimal),
# string.digits (decimal), string.octdigits (octal)
# and BASE2_DIGITS (binary)
#
# Unsigned numbers only since the '-' character could also be
# used as a digit.
#
# All the parameters should be Strings!
#
# data ... number that should be transcoded
# target ... target system the number should be encoded to
# source ... system the number is currently encoded in
#
def transcode(data, target, source):
return encode( decode( data, source ), target )
Wollt das halt lieber nochmal mit dir absprechen bevor ich den einbaue.
Verwenden könnte man das ganze etwa folgender maßen:
import encode
# hex -> Base64
print encode.transcode('AFFE123456789', encode.BASE64_DIGITS, encode.BASE16_DIGITS)
# dezimal in irgendein willkürliches encoding
print encode.transcode('9999998887', '?_:D-O.o', '0123456789')
Hab jetzt noch nicht wirklich getestet ob die Ergebnis auch stimmen, sieht soweit aber nicht schlecht aus.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.