2 | Go | marek_z_piekarek | 2024-04-19 11:02:35 | not approved |
// passgen <thinkofher, github.com/thinkofher>
//
// Go is truth.
//
// Building and usage:
//
// $ go build -o passgen .
// $ ./passgen 32
// OHa0)j3:MijW%u)j1g{{siz/'NTx=QMv
// $ ./passgen 16
// %(k9pD+]52dPU/-
//
package main
import (
"fmt"
"math/rand"
"os"
"strconv"
"time"
)
// You have to start with something
// clever, right? No? Whatever.
const MIN = int('!')
const MAX = int('}')
func main() {
// First argument is always program that you run.
// So if user provides less than two arguments, that means
// he/she's providing zero arguments, that we can call useful.
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "You have to provide password length!")
// That's old unix tradition.
// Things gone wrong? Return 1 and forget.
os.Exit(1)
}
// Convert first (not counting program name) argument to integer.
passLen, err := strconv.Atoi(os.Args[1])
if err != nil {
// Error occurs! That means user had tried to trick us
// and write something stupid like 'foobar' instead of
// giving us sweet like poney-honey password length as integer
// number.
fmt.Fprintf(os.Stderr, "%s is not a numerical value!", os.Args[1])
os.Exit(1)
}
if passLen < 0 {
// You thought that I missed that detail?
// I must admit, you're really smart, but not
// smarter than my password generator!
fmt.Fprintf(os.Stderr, "Password length can not be negative number.")
os.Exit(1)
}
// Do you remember that? I bet you do.
// Namespaces are good. Don't fight them!
// They will never harm you if you'll treat them
// with due respect.
rand.Seed(time.Now().UnixNano())
// That's something new.
result := make([]byte, passLen)
// And finally.
for i := range result {
result[i] = byte(rand.Intn(MAX-MIN) + MIN)
}
// We're home.
fmt.Fprintf(os.Stdin, "%s", string(result))
// Of course don't use that stupid password.
// Computers doesn't give a damn about how
// funny are bytes in your password, as long
// as you have many of them.
}
click to show comments
500 | C <3 | test | 2019-02-07 23:57:06 | not approved |
19 | javascript | Nabiał | 2018-11-29 15:26:52 | not approved |
<!DOCTYPE html>
<html><head></head><body onload="gsh()"><script>
function gsh()
{
var text = "";
possible = ["ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz", "0123456789", "!@#$%^&*()_+{}[]|;':<>?,./`~"];
var characters = parseInt(Math.random() * 248 + 8);
for(var c = 0; c < characters; ++c)
{
var poss = parseInt(Math.random() * 4);
text += possible[poss].charAt(parseInt(Math.random() * Object.keys(possible[poss]).length));
}
console.log(text);
}
</script></body></html>
click to show comments
518 | C | schrenker | 2018-11-28 19:21:05 | not approved |
#include<stdio.h>
main(){srand(time(0));for(int i;i<rand()%248+9;++i){putc(rand()%94+33,stdout);}}
click to show comments
500 | excel | mys7erion | 2018-11-23 18:40:45 | not approved |
212 | Pascal | Limak? Kamil = null; | 2018-11-22 12:15:11 | not approved |
var s:string;
len:Longint;
begin
Randomize;
s:='';
for len:=Random(249)+8 downto 0 do
s:=s+chr(Random(94)+33);
writeln(s);
end.
click to show comments
1 | sql | mys7erion | 2018-11-22 11:32:03 | not approved |
nie usuwac tego, bo bez tego nie działa
jak edytować?
click to show comments -> click to edit
albo
kilkasz na swój login na navbarze -> click to edit przy kodzie
click to show comments
1208 | Python | Limak? Kamil = null; | 2018-11-21 20:14:17 | not approved |
from random import randrange as r
print(''.join([chr(r(93)+33) for i in range(r(248)+8)]))
click to show comments
#include<stdio.h>
main(){int a;srand(&a);for(a=rand()%249+8;--a;printf("%c",rand()%94+33));}
click to show comments
238 | VBS | BigDinDonMan | 2018-11-21 13:47:07 | not approved |
Randomize(0)
dim s(95)
x = 0
i = 33
do while i < 128
s(x) = chr(i)
i = i + 1
x = x + 1
loop
res = ""
x = (256 - 8 + 1) * rnd() + 8
for i = 0 to x
res = res&cstr(s(rnd() * 95))
next
msgbox res
click to show comments
381 | Ruby | BigDinDonMan | 2018-11-21 13:25:43 | not approved |
s, _s = "", ""
i, j = 33, 128
while i < j do
s+=i.chr
i+=1
end
n, i = 8+rand(256 - 8), 0
while i < n do
_s+=s[rand(s.length)]
i+=1
end
print _s
click to show comments
#include<stdio.h>
main(){int a;srand(&a);char b[a=rand()%249+8];for(int i=0;i<a;b[i++]=rand()%94+33);puts(b);}
click to show comments
#include<stdio.h>
main(){int c;srand(&c);int a=rand()%249+8;char b[a];for(int i=0;i<a;b[i++]=rand()%94+33);printf("%s",b);}
click to show comments
31 | C# | BigDinDonMan | 2018-11-20 19:15:07 | not approved |
using System;
using System.Collections.Generic;
namespace Password {
class Program {
static void Main(string[] args) {
Random rand = new Random();
char[] chars = new char[127 - 33 + 1];
for (int i = 33, j = 0; i <= 127; ++i, chars[j] = (char)i, ++j);
int count = rand.Next(8, 257);
List<char> pass = new List<char>();
for (int i = 0; i < count; pass.Add(chars[rand.Next(0, chars.Length)]), ++i);
Console.WriteLine(new string(pass.ToArray()));
}
}
}
click to show comments
157 | Python | BigDinDonMan | 2018-11-20 18:56:58 | not approved |
from string import digits, ascii_letters, punctuation
from random import randint
chars = digits + ascii_letters + punctuation
amount = randint(8, 256)
password = [chars[randint(0, len(chars) - 1)] for i in range(amount)]
print("".join(password))
click to show comments
129 | Python | mmnow | 2018-11-20 15:56:16 | not approved |
import random
import string
charset = string.ascii_letters + string.digits + string.punctuation
def gen(length: int) -> str:
if not 8 <= length <= 256: raise Exception(f"Wrong length: {length}")
return ''.join([random.choice(charset) for i in range(0, length)])
click to show comments
vim tryToExitThis.txt
click to show comments